APIs

Show:
  1. /**
  2. Block property is a singleton Backbone view that represents shared UI view for all Blocks (Channels and Scenes blocks).
  3. It lives inside PropertiesViews
  4. @class BlockProperties
  5. @constructor
  6. @return {object} instantiated BlockProperties
  7. **/
  8. define(['jquery', 'backbone', 'Knob', 'nouislider', 'gradient', 'spinner', 'FontSelector', 'RSSLinks', 'MRSSLinks', 'BarMeterView', 'timepicker', 'datepicker', 'bootstrap-table-editable', 'bootstrap-table-sort-rows', 'LiveInput'], function ($, Backbone, Knob, nouislider, gradient, spinner, FontSelector, RSSLinks, MRSSLinks, BarMeterView, timepicker, datepicker, bootstraptableeditable, bootstraptablesortrows, LiveInput) {
  9.  
  10. /**
  11. Custom event fired when a gradient color picked
  12. @event COLOR_SELECTED
  13. @param {this} caller
  14. @param {self} context caller
  15. @param {Event} event
  16. @static
  17. @final
  18. **/
  19. BB.EVENTS.GRADIENT_COLOR_CHANGED = 'GRADIENT_COLOR_CHANGED';
  20.  
  21. /**
  22. Custom YouTube event fired when bar meter changed event
  23. @event YOUTUBE_METER_QUALITY_CHANGED
  24. @param {This} caller
  25. @param {Self} context caller
  26. @param {Event}
  27. @static
  28. @final
  29. **/
  30. BB.EVENTS.YOUTUBE_METER_QUALITY_CHANGED = 'YOUTUBE_METER_QUALITY_CHANGED';
  31.  
  32.  
  33. /**
  34. Custom Location priority event fired when bar meter changed event
  35. @event LOCATION_PRIORITY_METER_CHANGED
  36. @param {This} caller
  37. @param {Self} context caller
  38. @param {Event}
  39. @static
  40. @final
  41. **/
  42. BB.EVENTS.LOCATION_PRIORITY_METER_CHANGED = 'LOCATION_PRIORITY_METER_CHANGED';
  43.  
  44.  
  45. /**
  46. Custom event fired when gradient color selection picker closed
  47. @event GRADIENT_COLOR_CLOSED
  48. @param {this} caller
  49. @param {self} context caller
  50. @param {Event} event
  51. @static
  52. @final
  53. **/
  54. BB.EVENTS.GRADIENT_COLOR_CLOSED = 'GRADIENT_COLOR_CLOSED';
  55.  
  56. /**
  57. event fires when fasterq background color changed
  58. @event Block.FASTERQ_BG_COLOR_CHANGE
  59. @param {this} caller
  60. @param {String} selected block_id
  61. **/
  62. BB.EVENTS.FASTERQ_BG_COLOR_CHANGE = 'FASTERQ_BG_COLOR_CHANGE';
  63.  
  64. /**
  65. event fires when block length is changing (requesting a change), normally by a knob property widget
  66. @event BLOCK_LENGTH_CHANGING
  67. @param {Object} this
  68. @param {Object} caller the firing knob element
  69. @param {Number} value the knob's position value (hours / minutes / seconds)
  70. **/
  71. BB.EVENTS.BLOCK_LENGTH_CHANGING = 'BLOCK_LENGTH_CHANGING';
  72.  
  73. /**
  74. event fires when background alpha changed
  75. @event ALPHA_CHANGED
  76. @param {Object} this
  77. @param {Object} caller the firing element
  78. @param {Number} alpha value
  79. **/
  80. BB.EVENTS.ALPHA_CHANGED = 'ALPHA_CHANGED';
  81.  
  82. /**
  83. event fires when video volume changed
  84. @event VIDEO_VOLUME_CHANGED
  85. @param {Object} this
  86. @param {Object} caller the firing element
  87. @param {Number} alpha value
  88. **/
  89. BB.EVENTS.VIDEO_VOLUME_CHANGED = 'VIDEO_VOLUME_CHANGED';
  90.  
  91. /**
  92. event fires when youtube volume changed
  93. @event YOUTUBE_VOLUME_CHANGED
  94. @param {Object} this
  95. @param {Object} caller the firing element
  96. @param {Number} alpha value
  97. **/
  98. BB.EVENTS.YOUTUBE_VOLUME_CHANGED = 'YOUTUBE_VOLUME_CHANGED';
  99.  
  100. /**
  101. event fires when radius of location changed
  102. @event LOCATION_RADIUS_CHANGED
  103. @param {Object} this
  104. @param {Object} caller the firing element
  105. @param {Number} alpha value
  106. **/
  107. BB.EVENTS.LOCATION_RADIUS_CHANGED = 'LOCATION_RADIUS_CHANGED';
  108.  
  109. /**
  110. event fires datagrid collection is dragged
  111. @event COLLECTION_ROW_DRAG
  112. @param {Object} this
  113. @param {Object} caller the firing element
  114. @param {Number} alpha value
  115. **/
  116. BB.EVENTS.COLLECTION_ROW_DRAG = 'COLLECTION_ROW_DRAG';
  117.  
  118. /**
  119. event fires datagrid collection is dropped
  120. @event COLLECTION_ROW_DROP
  121. @param {Object} this
  122. @param {Object} caller the firing element
  123. @param {Number} alpha value
  124. **/
  125. BB.EVENTS.COLLECTION_ROW_DROP = 'COLLECTION_ROW_DROP';
  126.  
  127. /**
  128. event fires datagrid collection data changed / saved
  129. @event COLLECTION_ROW_CHANGED
  130. @param {Object} this
  131. @param {Object} caller the firing element
  132. @param {Number} alpha value
  133. **/
  134. BB.EVENTS.COLLECTION_ROW_CHANGED = 'COLLECTION_ROW_CHANGED';
  135.  
  136. /**
  137. event fires datagrid collection event data chnaged / saved
  138. @event COLLECTION_EVENT_ROW_CHANGED
  139. @param {Object} this
  140. @param {Object} caller the firing element
  141. @param {Number} alpha value
  142. **/
  143. BB.EVENTS.COLLECTION_EVENT_ROW_CHANGED = 'COLLECTION_EVENT_ROW_CHANGED';
  144.  
  145. /**
  146. event fires datagrid location row is dragged
  147. @event LOCATION_ROW_DRAG
  148. @param {Object} this
  149. @param {Object} caller the firing element
  150. @param {Number} alpha value
  151. **/
  152. BB.EVENTS.LOCATION_ROW_DRAG = 'LOCATION_ROW_DRAG';
  153.  
  154. /**
  155. event fires datagrid location row is dropped
  156. @event LOCATION_ROW_DROP
  157. @param {Object} this
  158. @param {Object} caller the firing element
  159. @param {Number} alpha value
  160. **/
  161. BB.EVENTS.LOCATION_ROW_DROP = 'LOCATION_ROW_DROP';
  162.  
  163. /**
  164. event fires datagrid location row data changed / saved
  165. @event LOCATION_ROW_CHANGED
  166. @param {Object} this
  167. @param {Object} caller the firing element
  168. @param {Number} alpha value
  169. **/
  170. BB.EVENTS.LOCATION_ROW_CHANGED = 'LOCATION_ROW_CHANGED';
  171.  
  172. /**
  173. event fires when location live input value chanegs such as LAT/LNG/resource names
  174. @event LOCATION_LIVE_INPUT_CHANGED
  175. @param {Object} this
  176. @param {Object} caller the firing element
  177. @param {Number} alpha value
  178. **/
  179. BB.EVENTS.LOCATION_LIVE_INPUT_CHANGED = 'LOCATION_LIVE_INPUT_CHANGED';
  180.  
  181.  
  182. /**
  183. event fires when new location point adding to google maps
  184. @event Block.ADD_LOCATION_POINT
  185. @param {this} caller
  186. @param {String} selected block_id
  187. **/
  188. BB.EVENTS.ADD_LOCATION_POINT = 'ADD_LOCATION_POINT';
  189.  
  190. BB.SERVICES.BLOCK_PROPERTIES = 'BlockProperties';
  191.  
  192. var BlockProperties = BB.View.extend({
  193.  
  194. /**
  195. Constructor
  196. @method initialize
  197. **/
  198. initialize: function () {
  199. var self = this;
  200.  
  201. BB.comBroker.setService(BB.SERVICES.BLOCK_PROPERTIES, self);
  202.  
  203. this.m_property = BB.comBroker.getService(BB.SERVICES['PROPERTIES_VIEW']);
  204. self.m_property.initPanel(Elements.BLOCK_PROPERTIES);
  205. self.m_rssFontSelector = undefined;
  206. self.m_loadedOnceCollectionDatagrid = false;
  207. self.m_loadedOnceJsonDatagrid = false;
  208. self.m_loadedOnceLocationDatagrid = false;
  209.  
  210. self._alphaSliderInit();
  211. self._bgGradientInit();
  212. self._bgSceneInit();
  213. self._bgFasterQColorInit();
  214. self._borderSceneColorInit();
  215. self._propLengthKnobsInit();
  216. self._videoVolumeSliderInit();
  217. self._youtubeVolumeSliderInit();
  218. self._youtubeInit();
  219. self._locationLiveInputs();
  220. self._locationRadiusSliderInit();
  221. self._locationPriorityInit();
  222. self._rssFontSelectorInit();
  223. self._rssSourceSelectorInit();
  224. self._mrssSourceSelectorInit();
  225. self._timepickerDayDurationInit();
  226. self._datepickerDayDurationInit();
  227. self._rssPollTimeInit();
  228. self._fasterQInit();
  229. self._labelFontSelectorInit();
  230. self._jsonItemFontSelectorInit();
  231. self._twitterFontSelectorInit();
  232. self._labelClockFontSelectorInit();
  233. },
  234.  
  235. /**
  236. Init alpha slider UI in the common properties
  237. @method _alphaSliderInit
  238. **/
  239. _alphaSliderInit: function () {
  240. var self = this;
  241. $(Elements.BLOCK_ALPHA_SLIDER).noUiSlider({
  242. handles: 1,
  243. start: 100,
  244. step: 1,
  245. range: [0, 100],
  246. serialization: {
  247. to: [$(Elements.BLOCK_ALPHA_LABEL), 'text']
  248. }
  249. });
  250. self.m_blockAlphaHandler = $(Elements.BLOCK_ALPHA_SLIDER).on('change', function (e) {
  251. var alpha = parseFloat($(Elements.BLOCK_ALPHA_SLIDER).val()) / 100;
  252. BB.comBroker.fire(BB.EVENTS.ALPHA_CHANGED, this, self, alpha)
  253. return false;
  254. });
  255. },
  256.  
  257. /**
  258. Load jquery gradient component once
  259. @method _bgGradientInit
  260. **/
  261. _bgGradientInit: function () {
  262. var self = this;
  263.  
  264. var lazyUpdateBgColor = _.debounce(function (points, styles) {
  265. if (points.length == 0)
  266. return;
  267. BB.comBroker.fire(BB.EVENTS.GRADIENT_COLOR_CHANGED, self, null, {points: points, styles: styles});
  268. }, 50);
  269.  
  270. var gradientColorPickerClosed = function () {
  271. log('render gradient');
  272. BB.comBroker.fire(BB.EVENTS.GRADIENT_COLOR_CLOSED, self, null);
  273. };
  274.  
  275. $(Elements.BG_COLOR_GRADIENT_SELECTOR).gradientPicker({
  276. change: lazyUpdateBgColor,
  277. closed: gradientColorPickerClosed,
  278. fillDirection: "90deg"
  279. });
  280.  
  281. // always close gradient color picker on mouseout
  282. $('.colorpicker').on('mouseleave', function (e) {
  283. $(document).trigger('mousedown');
  284. BB.comBroker.fire(BB.EVENTS.GRADIENT_COLOR_CLOSED, self, self);
  285. });
  286.  
  287. // to destroy the plugin instance
  288. // gradient = {}; $(Elements.BG_COLOR_GRADIENT_SELECTOR).remove();
  289. },
  290.  
  291. /**
  292. Init the scene background selector
  293. @method _bgSceneInit
  294. **/
  295. _bgSceneInit: function () {
  296. var self = this;
  297. var colorSettings = {
  298. animationSpeed: 50,
  299. animationEasing: 'swing',
  300. change: $.proxy(self._onSceneBgColorSelected, self),
  301. changeDelay: 100,
  302. control: 'hue',
  303. value: '#ffffff',
  304. defaultValue: '#428bca',
  305. show: $.proxy(self._onSceneColorToggle, self),
  306. hide: $.proxy(self._onSceneColorToggle, self),
  307. hideSpeed: 100,
  308. inline: false,
  309. letterCase: 'lowercase',
  310. opacity: false,
  311. position: 'bottom left',
  312. showSpeed: 100,
  313. theme: 'bootstrap'
  314. };
  315. $(Elements.SCENE_BACKGROUND_SELECTOR).minicolors(colorSettings);
  316. },
  317.  
  318. /**
  319. Init the fasterq background color selector
  320. @method _bgFasterQColorInit
  321. **/
  322. _bgFasterQColorInit: function () {
  323. var self = this;
  324. // show: $.proxy(self._onSceneColorToggle, self),
  325. // hide: $.proxy(self._onSceneColorToggle, self),
  326. var colorSettings = {
  327. animationSpeed: 50,
  328. animationEasing: 'swing',
  329. change: $.proxy(self._onFasterQBgColorSelected, self),
  330. changeDelay: 100,
  331. control: 'hue',
  332. value: '#ffffff',
  333. defaultValue: '#428bca',
  334. hideSpeed: 100,
  335. inline: false,
  336. letterCase: 'lowercase',
  337. opacity: false,
  338. position: 'bottom left',
  339. showSpeed: 100,
  340. theme: 'bootstrap'
  341. };
  342. $(Elements.FASTERQ_BLOCK_COLOR_SELECTOR).minicolors(colorSettings);
  343. },
  344.  
  345. /**
  346. Init the scene backgroud selector
  347. @method _bgSceneInit
  348. **/
  349. _borderSceneColorInit: function () {
  350. var self = this;
  351. var colorSettings = {
  352. animationSpeed: 50,
  353. animationEasing: 'swing',
  354. change: $.proxy(self._onSceneBorderColorSelected, self),
  355. changeDelay: 100,
  356. control: 'hue',
  357. value: '#ffffff',
  358. defaultValue: '#428bca',
  359. show: $.proxy(self._onSceneColorToggle, self),
  360. hide: $.proxy(self._onSceneColorToggle, self),
  361. hideSpeed: 100,
  362. inline: false,
  363. letterCase: 'lowercase',
  364. opacity: false,
  365. position: 'bottom left',
  366. showSpeed: 100,
  367. theme: 'bootstrap'
  368. };
  369. $(Elements.SCENE_BORDER_COLOR_SELECTOR).minicolors(colorSettings);
  370. },
  371. /**
  372. On fasterQ background color selected by minicolors
  373. @method _onFasterQBgColorSelected
  374. @param {String} i_color
  375. **/
  376. _onFasterQBgColorSelected: function (i_color) {
  377. var self = this;
  378. BB.comBroker.fire(BB.EVENTS.FASTERQ_BG_COLOR_CHANGE, self, self, i_color);
  379. },
  380.  
  381. /**
  382. On scene block border color selected by minicolors
  383. @method _onSceneBorderColorSelected
  384. @param {String} i_color
  385. **/
  386. _onSceneBorderColorSelected: function (i_color) {
  387. var self = this;
  388. if (self.m_showBorderOn)
  389. BB.comBroker.fire(BB.EVENTS.BLOCK_BORDER_CHANGE, self, self, i_color);
  390. },
  391.  
  392. _onSceneColorToggle: function (e) {
  393. var self = this;
  394. if (self.m_showBorderOn) {
  395. self.m_showBorderOn = undefined;
  396. } else {
  397. self.m_showBorderOn = 1;
  398. }
  399.  
  400. },
  401.  
  402. /**
  403. On scene background color selected by minicolors
  404. @method _onSceneBgColorSelected
  405. @param {String} i_color
  406. **/
  407. _onSceneBgColorSelected: function (i_color) {
  408. var self = this;
  409. BB.comBroker.fire(BB.EVENTS.SCENE_BG_COLOR_CHANGED, self, self, i_color);
  410. },
  411.  
  412. /**
  413. Create the block length knobs so a user can set the length of the block with respect to timeline_channel
  414. @method _propLengthKnobsInit
  415. @return none
  416. **/
  417. _propLengthKnobsInit: function () {
  418. var snippet = '<input id="blockLengthHours" data-displayPrevious="false" data-min="0" data-max="23" data-skin="tron" data-width="60" data-height="60" data-thickness=".2" type="text" class="knob" data-fgColor="gray">' +
  419. '<input id="blockLengthMinutes" data-displayPrevious="false" data-min="0" data-max="59" data-skin="tron" data-width="60" data-height="60" data-thickness=".2" type="text" class="knob" data-fgColor="gray">' +
  420. '<input id="blockLengthSeconds" data-displayPrevious="false" data-min="0" data-max="59" data-skin="tron" data-width="60" data-height="60" data-thickness=".2" type="text" class="knob" data-fgColor="gray">';
  421.  
  422. $(Elements.CHANNEL_BLOCK_PROPS).append(snippet);
  423.  
  424. $(Elements.CLASS_KNOB).knob({
  425. /*change: function (value) {
  426. console.log("change : " + value);
  427. var caller = this['i'][0].id;
  428. },*/
  429. release: function (value) {
  430. // console.log(this.$.attr('value'));
  431. // console.log("release : " + value + ' ' + this['i'][0].id);
  432. var caller = this['i'][0].id;
  433. BB.comBroker.fire(BB.EVENTS.BLOCK_LENGTH_CHANGING, this, caller, value);
  434. },
  435. /*cancel: function () {
  436. console.log("cancel : ", this);
  437. },*/
  438. draw: function () {
  439. if (this.$.data('skin') == 'tron') {
  440.  
  441. var a = this.angle(this.cv) // Angle
  442. , sa = this.startAngle // Previous start angle
  443. , sat = this.startAngle // Start angle
  444. , ea // Previous end angle
  445. , eat = sat + a // End angle
  446. , r = 1;
  447.  
  448. this.g.lineWidth = this.lineWidth;
  449.  
  450. this.o.cursor
  451. && (sat = eat - 0.3)
  452. && (eat = eat + 0.3);
  453.  
  454. if (this.o.displayPrevious) {
  455. ea = this.startAngle + this.angle(this.v);
  456. this.o.cursor
  457. && (sa = ea - 0.3)
  458. && (ea = ea + 0.3);
  459. this.g.beginPath();
  460. this.g.strokeStyle = this.pColor;
  461. this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sa, ea, false);
  462. this.g.stroke();
  463. }
  464.  
  465. this.g.beginPath();
  466. this.g.strokeStyle = r ? this.o.fgColor : this.fgColor;
  467. this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sat, eat, false);
  468. this.g.stroke();
  469.  
  470. this.g.lineWidth = 2;
  471. this.g.beginPath();
  472. this.g.strokeStyle = this.o.fgColor;
  473. this.g.arc(this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false);
  474. this.g.stroke();
  475.  
  476. return false;
  477. }
  478. }
  479. });
  480. },
  481.  
  482. /**
  483. Init video volume slider in properties
  484. @method _videoVolumeSliderInit
  485. **/
  486. _videoVolumeSliderInit: function () {
  487. var self = this;
  488. $(Elements.VIDEO_VOLUME_WRAP_SLIDER).noUiSlider({
  489. handles: 1,
  490. start: 100,
  491. step: 1,
  492. range: [0, 100],
  493. serialization: {
  494. to: [$(Elements.VIDEO_VOLUME_LABEL), 'text']
  495. }
  496. });
  497. self.m_videoVolumeHandler = $(Elements.VIDEO_VOLUME_WRAP_SLIDER).on('change', function (e) {
  498. var volume = parseFloat($(Elements.VIDEO_VOLUME_WRAP_SLIDER).val()) / 100;
  499. BB.comBroker.fire(BB.EVENTS.VIDEO_VOLUME_CHANGED, this, self, volume);
  500. return false;
  501. });
  502. },
  503.  
  504. /**
  505. Init youtube volume slider in properties
  506. @method _videoVolumeSliderInit
  507. **/
  508. _youtubeVolumeSliderInit: function () {
  509. var self = this;
  510. $(Elements.YOUTUBE_VOLUME_WRAP_SLIDER).noUiSlider({
  511. handles: 1,
  512. start: 100,
  513. step: 1,
  514. range: [0, 100],
  515. serialization: {
  516. to: [$(Elements.YOUTUBE_VOLUME_LABEL), 'text']
  517. }
  518. });
  519. self.m_youtuneVolumeHandler = $(Elements.YOUTUBE_VOLUME_WRAP_SLIDER).on('change', function (e) {
  520. var volume = parseFloat($(Elements.YOUTUBE_VOLUME_WRAP_SLIDER).val()) / 100;
  521. BB.comBroker.fire(BB.EVENTS.YOUTUBE_VOLUME_CHANGED, this, self, volume);
  522. return false;
  523. });
  524. },
  525.  
  526. /**
  527. Bind to location Live Inputs widgets
  528. @method _locationLiveInputs
  529. **/
  530. _locationLiveInputs: function(){
  531. var self = this;
  532. self.m_liveLocation = {};
  533. self.m_liveLocation[Elements.LOCATION_RESOURCE_NAME] = new LiveInput({
  534. el: Elements.LOCATION_RESOURCE_NAME,
  535. dataLocalize: 'name',
  536. placeHolder: 'name',
  537. value: 'name',
  538. customEvent: BB.EVENTS.LOCATION_LIVE_INPUT_CHANGED
  539. });
  540. self.m_liveLocation[Elements.LOCATION_RESOURCE_LAT] = new LiveInput({
  541. el: Elements.LOCATION_RESOURCE_LAT,
  542. dataLocalize: 'latitude',
  543. placeHolder: 'latitude',
  544. value: 'latitude',
  545. customEvent: BB.EVENTS.LOCATION_LIVE_INPUT_CHANGED
  546. });
  547. self.m_liveLocation[Elements.LOCATION_RESOURCE_LNG] = new LiveInput({
  548. el: Elements.LOCATION_RESOURCE_LNG,
  549. dataLocalize: 'longitude',
  550. placeHolder: 'longitude',
  551. value: 'longitude',
  552. customEvent: BB.EVENTS.LOCATION_LIVE_INPUT_CHANGED
  553. });
  554.  
  555. var input = self.m_liveLocation[Elements.LOCATION_RESOURCE_DURATION] = new LiveInput({
  556. el: Elements.LOCATION_RESOURCE_DURATION,
  557. dataLocalize: 'duration',
  558. placeHolder: 'duration',
  559. value: '5',
  560. customEvent: BB.EVENTS.LOCATION_LIVE_INPUT_CHANGED
  561. }).on('LIVE_INPUT_CHANGED', function (e) {
  562. }
  563. ).on('LIVE_INPUT_VALID_ERROR', function (e) {
  564. }
  565. );
  566. input.rules({
  567. 1: [
  568. input.getValidator().isNumberInRange, $(Elements.MSG_LIVEINPUT_SECONDS).text(), {
  569. min: 5,
  570. max: 86400
  571. }]
  572. });
  573. },
  574.  
  575. /**
  576. Init location radius slider in properties
  577. @method _locationRadiusSliderInit
  578. **/
  579. _locationRadiusSliderInit: function () {
  580. var self = this;
  581. $(Elements.LOCATION_RADIUS_WRAP_SLIDER).noUiSlider({
  582. handles: 1,
  583. start: 1,
  584. step: 0.10,
  585. range: [0.10, 4],
  586. serialization: {
  587. to: [$(Elements.LOCATION_RADIUS_LABEL), 'text']
  588. }
  589. });
  590. self.m_locationRadiusHandle = $(Elements.LOCATION_RADIUS_WRAP_SLIDER).on('change', function (e) {
  591. var val = $(Elements.LOCATION_RADIUS_WRAP_SLIDER).val();
  592. BB.comBroker.fire(BB.EVENTS.LOCATION_RADIUS_CHANGED, this, self, val);
  593. return false;
  594. });
  595. },
  596.  
  597. /**
  598. Create instance of RSSLink used in select property settings
  599. @method _rssSourceSelectorInit
  600. **/
  601. _rssSourceSelectorInit: function () {
  602. var self = this;
  603. self.m_rssLinkSelector = new RSSLinks({
  604. el: Elements.RSS_SOURCE
  605. });
  606. },
  607.  
  608. /**
  609. Create instance of RSSLink used in select property settings
  610. @method _rssSourceSelectorInit
  611. **/
  612. _mrssSourceSelectorInit: function () {
  613. var self = this;
  614. self.m_mrssLinkSelector = new MRSSLinks({
  615. el: Elements.MRSS_SOURCE
  616. });
  617. },
  618.  
  619. /**
  620. Create instance of FontSelector used in font property settings
  621. @method _rssFontSelectorInit
  622. **/
  623. _rssFontSelectorInit: function () {
  624. var self = this;
  625. self.m_rssFontSelector = new FontSelector({
  626. appendTo: Elements.RSS_FONT_SETTINGS,
  627. colorSettings: {animationSpeed: 100}
  628. });
  629. },
  630.  
  631. /**
  632. Init the time picker duration bootstrap widget
  633. @method _timepickerDayDurationInit
  634. **/
  635. _timepickerDayDurationInit: function () {
  636. var self = this;
  637. $(Elements.TIME_PICKER_TIME_INPUT).timepicker({
  638. showSeconds: true,
  639. showMeridian: false,
  640. defaultTime: false,
  641. minuteStep: 1,
  642. secondStep: 1
  643. });
  644.  
  645. $(Elements.TIME_PICKER_DURATION_INPUT).timepicker({
  646. showSeconds: true,
  647. showMeridian: false,
  648. defaultTime: false,
  649. minuteStep: 1,
  650. secondStep: 1
  651. });
  652. },
  653.  
  654. /**
  655. Init the date picker duration bootstrap widget
  656. @method _datepickerDayDurationInit
  657. **/
  658. _datepickerDayDurationInit: function () {
  659. var self = this;
  660. $(Elements.CLASS_TIME_PICKER_SCHEDULER).datepicker({
  661. autoclose: true,
  662. todayHighlight: true
  663. });
  664. },
  665.  
  666. /**
  667. Init the poll timer spinner widget
  668. @method _rssPollTimeInit
  669. @param {Number} _rssPollTimeInit
  670. **/
  671. _rssPollTimeInit: function () {
  672. var self = this;
  673. $(Elements.RSS_POLL_SPINNER).spinner({
  674. value: 30,
  675. min: 1,
  676. max: 30,
  677. step: 1
  678. });
  679. },
  680.  
  681. /**
  682. Init the youtube properties
  683. @method _youtubeInit
  684. **/
  685. _youtubeInit: function () {
  686. var self = this;
  687. self.m_youtubeQualityMeter = new BarMeterView({
  688. el: Elements.YOUTUBE_QUALITY_METER,
  689. customEvent: BB.EVENTS.YOUTUBE_METER_QUALITY_CHANGED
  690. });
  691. },
  692.  
  693. /**
  694. Init the location priority widget
  695. @method _locationPriorityInit
  696. **/
  697. _locationPriorityInit: function () {
  698. var self = this;
  699. self.m_locationPriorityMeter = new BarMeterView({
  700. el: Elements.LOCATION_PRIORITY_METER,
  701. customEvent: BB.EVENTS.LOCATION_PRIORITY_METER_CHANGED
  702. });
  703. },
  704.  
  705. /**
  706. Init the fasterq properties
  707. @method _fasterQInit
  708. **/
  709. _fasterQInit: function () {
  710. var self = this;
  711. },
  712.  
  713. /**
  714. Create instance of FontSelector used in font property settings for label block
  715. @method _labelFontSelectorInit
  716. **/
  717. _labelFontSelectorInit: function () {
  718. var self = this;
  719. self.m_labelFontSelector = new FontSelector({
  720. appendTo: Elements.LABEL_FONT_SETTINGS,
  721. colorSettings: {animationSpeed: 100}
  722. });
  723. },
  724.  
  725. /**
  726. Create instance of FontSelector used in font json item block
  727. @method _jsonItemFontSelectorInit
  728. **/
  729. _jsonItemFontSelectorInit: function () {
  730. var self = this;
  731. self.m_jsonItemFontSelector = new FontSelector({
  732. appendTo: Elements.JSON_ITEM_FONT_SETTINGS,
  733. colorSettings: {animationSpeed: 100}
  734. });
  735. },
  736.  
  737. /**
  738. Create instance of FontSelector used in font property settings for twitter item block
  739. @method _twitterFontSelectorInit
  740. **/
  741. _twitterFontSelectorInit: function () {
  742. var self = this;
  743. self.m_twitterFontSelector = new FontSelector({
  744. appendTo: Elements.TWITTER_FONT_SETTINGS,
  745. colorSettings: {animationSpeed: 100}
  746. });
  747. },
  748.  
  749. /**
  750. Create instance of FontSelector used in font property settings
  751. @method _labelFontSelectorInit
  752. **/
  753. _labelClockFontSelectorInit: function () {
  754. var self = this;
  755. self.m_clockFontSelector = new FontSelector({
  756. appendTo: Elements.CLOCK_FONT_SETTINGS,
  757. colorSettings: {animationSpeed: 100}
  758. });
  759. },
  760.  
  761. /**
  762. Bring into view the Block property StackView panel
  763. @method viewPanel
  764. **/
  765. viewPanel: function (i_panel) {
  766. var self = this;
  767. self.m_property.viewPanel(i_panel);
  768. },
  769.  
  770. /**
  771. Bring into view the Block property StackView SubPanel
  772. @method showBlockProperty
  773. **/
  774. initSubPanel: function (i_panel) {
  775. var self = this;
  776. self.m_property.initSubPanel(i_panel);
  777. },
  778.  
  779. /**
  780. Bring into view the Block property Settings StackView SubPanel
  781. @method initSettingsPanel
  782. **/
  783. initSettingsPanel: function (i_panel) {
  784. var self = this;
  785. self.m_property.initSettingsPanel(i_panel);
  786. },
  787.  
  788. /**
  789. Bring into view the Block property StackView SubPanel
  790. @method showBlockProperty
  791. **/
  792. viewSubPanel: function (i_panel) {
  793. var self = this;
  794. self.m_property.viewSubPanel(i_panel);
  795. },
  796.  
  797. /**
  798. Bring into view the Block property StackView SubPanel
  799. @method showBlockProperty
  800. **/
  801. viewSettingsPanel: function (i_panel) {
  802. var self = this;
  803. self.m_property.viewSettingsPanel(i_panel);
  804. },
  805.  
  806. /**
  807. Set the value for LAT/LNG/Name for Location fields using the LiveInput widget
  808. @method setLocationLiveInput
  809. @param {String} i_el
  810. @param {String} i_value
  811. **/
  812. setLocationLiveInput: function (i_el, i_value) {
  813. var self = this;
  814. self.m_liveLocation[i_el].setValue(i_value);
  815. },
  816.  
  817. /**
  818. Set the color picker color of scene background
  819. @method setBgScenePropColorPicker
  820. @param {Number} i_color
  821. **/
  822. setBgScenePropColorPicker: function (i_color) {
  823. $(Elements.SCENE_BACKGROUND_SELECTOR).minicolors('value', i_color);
  824. },
  825.  
  826. /**
  827. Set the color picker color of scene border
  828. @method setBorderBlockPropColorPicker
  829. @param {String} i_color
  830. **/
  831. setBorderBlockPropColorPicker: function (i_color) {
  832. $(Elements.SCENE_BORDER_COLOR_SELECTOR).minicolors('value', i_color);
  833. },
  834.  
  835. /**
  836. Returns the instance of rss font selector
  837. @method getRssFontSelector
  838. @return {Object} m_rssFontSelector instance
  839. **/
  840. getRssFontSelector: function () {
  841. var self = this;
  842. return self.m_rssFontSelector;
  843. },
  844.  
  845. /**
  846. Returns the instance of clock font selector
  847. @method getClockFontSelector
  848. @return {Object} m_clockFontSelector instance
  849. **/
  850. getClockFontSelector: function () {
  851. var self = this;
  852. return self.m_clockFontSelector;
  853. },
  854.  
  855. /**
  856. Returns the instance of label font selector
  857. @method getLabelFontSelector
  858. @return {Object} font selector instance
  859. **/
  860. getLabelFontSelector: function () {
  861. var self = this;
  862. return self.m_labelFontSelector;
  863. },
  864.  
  865. /**
  866. Returns the instance of label json item font selector
  867. @method getLabelJsonItemFontSelector
  868. @return {Object} font selector instance
  869. **/
  870. getLabelJsonItemFontSelector: function () {
  871. var self = this;
  872. return self.m_jsonItemFontSelector;
  873. },
  874.  
  875. /**
  876. Returns the instance of twitter item font selector
  877. @method getTwitterItemFontSelector
  878. @return {Object} font selector instance
  879. **/
  880. getTwitterItemFontSelector: function () {
  881. var self = this;
  882. return self.m_twitterFontSelector;
  883. },
  884.  
  885. /**
  886. Returns the instance of youtube quality meter
  887. @method getYouTubeQualityMeter
  888. @return {Object} m_youtubeQualityMeter instance
  889. **/
  890. getYouTubeQualityMeter: function () {
  891. var self = this;
  892. return self.m_youtubeQualityMeter;
  893. },
  894.  
  895. /**
  896. Returns the instance of location priority meter
  897. @method getLocationPriorityMeter
  898. @return {Object} m_locationPriorityMeter instance
  899. **/
  900. getLocationPriorityMeter: function () {
  901. var self = this;
  902. return self.m_locationPriorityMeter;
  903. },
  904.  
  905. /**
  906. Returns the instance pf rss link selector
  907. @method getRssLinkSelector
  908. @return {Object} m_rssLinks instance
  909. **/
  910. getRssLinkSelector: function () {
  911. var self = this;
  912. return self.m_rssLinkSelector;
  913. },
  914.  
  915. /**
  916. Returns the instance pf mrss link selector
  917. @method getMRssLinkSelector
  918. @return {Object} m_mrssLinkSelector instance
  919. **/
  920. getMRssLinkSelector: function () {
  921. var self = this;
  922. return self.m_mrssLinkSelector;
  923. },
  924.  
  925. /**
  926. Init the collection bootstrap datatable
  927. @method collectionDatatableInit
  928. **/
  929. collectionDatatableInit: function () {
  930. var self = this;
  931. if (self.m_loadedOnceCollectionDatagrid)
  932. return;
  933. self.m_loadedOnceCollectionDatagrid = true;
  934. require(['bootstrap-table-editable', 'bootstrap-table-sort-rows'], function (bootstraptableeditable, bootstraptablesortrows) {
  935. self.m_collectionTable = $(Elements.COLLECTION_TABLE);
  936. self.m_collectionTable.bootstrapTable({
  937. data: [],
  938. editable: true,
  939. type: 'select',
  940. title: 'Select status',
  941. placement: 'left',
  942. onEditableInit: function (response, newValue) {
  943. //console.log(newValue);
  944. },
  945. onReorderRowsDrag: function (table, row) {
  946. BB.comBroker.fire(BB.EVENTS.COLLECTION_ROW_DRAG, this, self, $(row).attr('data-index'));
  947. },
  948. onReorderRowsDrop: function (table, row) {
  949. BB.comBroker.fire(BB.EVENTS.COLLECTION_ROW_DROP, this, self, $(row).attr('data-index'));
  950. },
  951. onEditableShown: function (response, newValue) {
  952. //console.log(newValue);
  953. },
  954. onEditableHidden: function (response, newValue) {
  955. //console.log(newValue);
  956. //console.log('getSelections: ' + JSON.stringify($table.bootstrapTable('getSelections')));
  957. //$table.bootstrapTable('refresh');
  958. },
  959. onEditableSave: function (response, newValue) {
  960. BB.comBroker.fire(BB.EVENTS.COLLECTION_ROW_CHANGED, this, self, newValue);
  961. },
  962. success: function (response, newValue) {
  963. if (response.status == 'error') {
  964. return response.msg;
  965. } //msg will be shown in editable form
  966. }
  967. });
  968.  
  969. self.m_collectionEventTable = $(Elements.COLLECTION_EVENTS_TABLE);
  970. self.m_collectionEventTable.bootstrapTable({
  971. data: [],
  972. editable: true,
  973. type: 'select',
  974. title: 'Select status',
  975. placement: 'left',
  976. onEditableInit: function (response, newValue) {
  977. //console.log(newValue);
  978. },
  979. onEditableSave: function (response, newValue) {
  980. BB.comBroker.fire(BB.EVENTS.COLLECTION_EVENT_ROW_CHANGED, this, self, newValue);
  981. },
  982. success: function (response, newValue) {
  983. if (response.status == 'error') {
  984. return response.msg;
  985. } //msg will be shown in editable form
  986. }
  987. });
  988. });
  989. },
  990.  
  991. /**
  992. Init the json event bootstrap datatable
  993. @method jsonEventDatatableInit
  994. **/
  995. jsonEventDatatableInit: function () {
  996. var self = this;
  997. if (self.m_loadedOnceJsonDatagrid)
  998. return;
  999. self.m_loadedOnceJsonDatagrid = true;
  1000. require(['bootstrap-table-editable', 'bootstrap-table-sort-rows'], function (bootstraptableeditable, bootstraptablesortrows) {
  1001. self.m_jsonEventTable = $(Elements.JSON_EVENTS_TABLE);
  1002. self.m_jsonEventTable.bootstrapTable({
  1003. data: [],
  1004. editable: true,
  1005. type: 'select',
  1006. title: 'Select status',
  1007. placement: 'left',
  1008. onEditableInit: function (response, newValue) {
  1009. //console.log(newValue);
  1010. },
  1011. onEditableSave: function (response, newValue) {
  1012. BB.comBroker.fire(BB.EVENTS.JSON_EVENT_ROW_CHANGED, this, self, newValue);
  1013. },
  1014. success: function (response, newValue) {
  1015. if (response.status == 'error') {
  1016. return response.msg;
  1017. } //msg will be shown in editable form
  1018. }
  1019. });
  1020. });
  1021. },
  1022.  
  1023. /**
  1024. Init the location base bootstrap datatable
  1025. @method locationDatatableInit
  1026. **/
  1027. locationDatatableInit: function () {
  1028. var self = this;
  1029. if (self.m_loadedOnceLocationDatagrid)
  1030. return;
  1031. self.m_loadedOnceLocationDatagrid = true;
  1032. require(['bootstrap-table-editable', 'bootstrap-table-sort-rows'], function (bootstraptableeditable, bootstraptablesortrows) {
  1033. self.m_locationTable = $(Elements.LOCATION_TABLE);
  1034. self.m_locationTable.bootstrapTable({
  1035. data: [],
  1036. editable: true,
  1037. type: 'select',
  1038. title: 'Select status',
  1039. placement: 'left',
  1040. onEditableInit: function (response, newValue) {
  1041. // console.log(newValue);
  1042. },
  1043. onReorderRowsDrag: function (table, row) {
  1044. BB.comBroker.fire(BB.EVENTS.LOCATION_ROW_DRAG, this, self, $(row).attr('data-index'));
  1045. },
  1046. onReorderRowsDrop: function (table, row) {
  1047. BB.comBroker.fire(BB.EVENTS.LOCATION_ROW_DROP, this, self, $(row).attr('data-index'));
  1048. },
  1049. onEditableShown: function (response, newValue) {
  1050. // console.log(newValue);
  1051. },
  1052. onEditableHidden: function (response, newValue) {
  1053. // console.log(newValue);
  1054. //console.log('getSelections: ' + JSON.stringify($table.bootstrapTable('getSelections')));
  1055. //$table.bootstrapTable('refresh');
  1056. },
  1057. onEditableSave: function (response, newValue) {
  1058. BB.comBroker.fire(BB.EVENTS.LOCATION_ROW_CHANGED, this, self, newValue);
  1059. },
  1060. success: function (response, newValue) {
  1061. if (response.status == 'error') {
  1062. return response.msg;
  1063. } //msg will be shown in editable form
  1064. }
  1065. });
  1066. });
  1067. }
  1068. });
  1069.  
  1070. return BlockProperties;
  1071. });
  1072.  
  1073.  
  1074.