newscript.js 109 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168
  1. var App = function () {
  2. var currentPage = ''; // current page
  3. var collapsed = false; //sidebar collapsed
  4. var is_mobile = false; //is screen mobile?
  5. var is_mini_menu = false; //is mini-menu activated
  6. var is_fixed_header = false; //is fixed header activated
  7. var responsiveFunctions = []; //responsive function holder
  8. var paydata = [];
  9. var regdata = [];
  10. var logindata = [];
  11. var upaydata = [];
  12. /*-----------------------------------------------------------------------------------*/
  13. /* Runs callback functions set by App.addResponsiveFunction()
  14. /*-----------------------------------------------------------------------------------*/
  15. var runResponsiveFunctions = function () {
  16. // reinitialize other subscribed elements
  17. for (var i in responsiveFunctions) {
  18. var each = responsiveFunctions[i];
  19. each.call();
  20. }
  21. }
  22. /*-----------------------------------------------------------------------------------*/
  23. /* To get the correct viewport width based on http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/
  24. /*-----------------------------------------------------------------------------------*/
  25. var getViewPort = function () {
  26. var e = window, a = 'inner';
  27. if (!('innerWidth' in window)) {
  28. a = 'client';
  29. e = document.documentElement || document.body;
  30. }
  31. return {
  32. width: e[a + 'Width'],
  33. height: e[a + 'Height']
  34. }
  35. }
  36. /*-----------------------------------------------------------------------------------*/
  37. /* Check layout size
  38. /*-----------------------------------------------------------------------------------*/
  39. var checkLayout = function() {
  40. //Check if sidebar has mini-menu
  41. is_mini_menu = $('#sidebar').hasClass('mini-menu');
  42. //Check if fixed header is activated
  43. is_fixed_header = $('#header').hasClass('navbar-fixed-top');
  44. }
  45. /*-----------------------------------------------------------------------------------*/
  46. /* Sidebar & Main Content size match
  47. /*-----------------------------------------------------------------------------------*/
  48. var handleSidebarAndContentHeight = function () {
  49. var content = $('#content');
  50. var sidebar = $('#sidebar');
  51. var body = $('body');
  52. var height;
  53. if (body.hasClass('sidebar-fixed')) {
  54. height = $(window).height() - $('#header').height() + 1;
  55. } else {
  56. height = sidebar.height() + 20;
  57. }
  58. if (height >= content.height()) {
  59. content.attr('style', 'min-height:' + height + 'px !important');
  60. }
  61. }
  62. /*-----------------------------------------------------------------------------------*/
  63. /* Sidebar
  64. /*-----------------------------------------------------------------------------------*/
  65. var handleSidebar = function () {
  66. jQuery('.sidebar-menu .has-sub > a').click(function () {
  67. var last = jQuery('.has-sub.open', $('.sidebar-menu'));
  68. last.removeClass("open");
  69. jQuery('.arrow', last).removeClass("open");
  70. jQuery('.sub', last).slideUp(200);
  71. var thisElement = $(this);
  72. var slideOffeset = -200;
  73. var slideSpeed = 200;
  74. var sub = jQuery(this).next();
  75. if (sub.is(":visible")) {
  76. jQuery('.arrow', jQuery(this)).removeClass("open");
  77. jQuery(this).parent().removeClass("open");
  78. sub.slideUp(slideSpeed, function () {
  79. if ($('#sidebar').hasClass('sidebar-fixed') == false) {
  80. App.scrollTo(thisElement, slideOffeset);
  81. }
  82. handleSidebarAndContentHeight();
  83. });
  84. } else {
  85. jQuery('.arrow', jQuery(this)).addClass("open");
  86. jQuery(this).parent().addClass("open");
  87. sub.slideDown(slideSpeed, function () {
  88. if ($('#sidebar').hasClass('sidebar-fixed') == false) {
  89. App.scrollTo(thisElement, slideOffeset);
  90. }
  91. handleSidebarAndContentHeight();
  92. });
  93. }
  94. });
  95. // Handle sub-sub menus
  96. jQuery('.sidebar-menu .has-sub .sub .has-sub-sub > a').click(function () {
  97. var last = jQuery('.has-sub-sub.open', $('.sidebar-menu'));
  98. last.removeClass("open");
  99. jQuery('.arrow', last).removeClass("open");
  100. jQuery('.sub', last).slideUp(200);
  101. var sub = jQuery(this).next();
  102. if (sub.is(":visible")) {
  103. jQuery('.arrow', jQuery(this)).removeClass("open");
  104. jQuery(this).parent().removeClass("open");
  105. sub.slideUp(200);
  106. } else {
  107. jQuery('.arrow', jQuery(this)).addClass("open");
  108. jQuery(this).parent().addClass("open");
  109. sub.slideDown(200);
  110. }
  111. });
  112. }
  113. /*-----------------------------------------------------------------------------------*/
  114. /* Collapse Sidebar Programatically
  115. /*-----------------------------------------------------------------------------------*/
  116. var collapseSidebar = function () {
  117. var iconElem = document.getElementById("sidebar-collapse").querySelector('[class*="fa-"]');
  118. var iconLeft = iconElem.getAttribute("data-icon1");
  119. var iconRight = iconElem.getAttribute("data-icon2");
  120. /* For Navbar */
  121. jQuery('.navbar-brand').addClass("mini-menu");
  122. /* For sidebar */
  123. jQuery('#sidebar').addClass("mini-menu");
  124. jQuery('#main-content').addClass("margin-left-50");
  125. jQuery('.sidebar-collapse i').removeClass(iconLeft);
  126. jQuery('.sidebar-collapse i').addClass(iconRight);
  127. /* Remove placeholder from Search Bar */
  128. jQuery('.search').attr('placeholder', '');
  129. collapsed = true;
  130. /* Set a cookie so that mini-sidebar persists */
  131. $.cookie('mini_sidebar', '1');
  132. }
  133. /*-----------------------------------------------------------------------------------*/
  134. /* Responsive Sidebar Collapse
  135. /*-----------------------------------------------------------------------------------*/
  136. var responsiveSidebar = function () {
  137. //Handle sidebar collapse on screen width
  138. var width = $(window).width();
  139. if ( width < 768 ) {
  140. is_mobile = true;
  141. //Hide the sidebar completely
  142. jQuery('#main-content').addClass("margin-left-0");
  143. }
  144. else {
  145. is_mobile = false;
  146. //Show the sidebar completely
  147. jQuery('#main-content').removeClass("margin-left-0");
  148. var menu = $('.sidebar');
  149. if (menu.parent('.slimScrollDiv').size() === 1) { // destroy existing instance before resizing
  150. menu.slimScroll({
  151. destroy: true
  152. });
  153. menu.removeAttr('style');
  154. $('#sidebar').removeAttr('style');
  155. }
  156. }
  157. }
  158. /*-----------------------------------------------------------------------------------*/
  159. /* Sidebar Collapse
  160. /*-----------------------------------------------------------------------------------*/
  161. var handleSidebarCollapse = function () {
  162. var viewport = getViewPort();
  163. if ($.cookie('mini_sidebar') === '1') {
  164. /* For Navbar */
  165. jQuery('.navbar-brand').addClass("mini-menu");
  166. /* For sidebar */
  167. jQuery('#sidebar').addClass("mini-menu");
  168. jQuery('#main-content').addClass("margin-left-50");
  169. collapsed = true;
  170. }
  171. //Handle sidebar collapse on user interaction
  172. jQuery('.sidebar-collapse').click(function () {
  173. //Handle mobile sidebar toggle
  174. if(is_mobile && !(is_mini_menu)){
  175. //If sidebar is collapsed
  176. if(collapsed){
  177. jQuery('body').removeClass("slidebar");
  178. jQuery('.sidebar').removeClass("sidebar-fixed");
  179. //Add fixed top nav if exists
  180. if(is_fixed_header) {
  181. jQuery('#header').addClass("navbar-fixed-top");
  182. jQuery('#main-content').addClass("margin-top-100");
  183. }
  184. collapsed = false;
  185. $.cookie('mini_sidebar', '0');
  186. }
  187. else {
  188. jQuery('body').addClass("slidebar");
  189. jQuery('.sidebar').addClass("sidebar-fixed");
  190. //Remove fixed top nav if exists
  191. if(is_fixed_header) {
  192. jQuery('#header').removeClass("navbar-fixed-top");
  193. jQuery('#main-content').removeClass("margin-top-100");
  194. }
  195. collapsed = true;
  196. $.cookie('mini_sidebar', '1');
  197. handleMobileSidebar();
  198. }
  199. }
  200. else { //Handle regular sidebar toggle
  201. var iconElem = document.getElementById("sidebar-collapse").querySelector('[class*="fa-"]');
  202. var iconLeft = iconElem.getAttribute("data-icon1");
  203. var iconRight = iconElem.getAttribute("data-icon2");
  204. //If sidebar is collapsed
  205. if(collapsed){
  206. /* For Navbar */
  207. jQuery('.navbar-brand').removeClass("mini-menu");
  208. /* For sidebar */
  209. jQuery('#sidebar').removeClass("mini-menu");
  210. jQuery('#main-content').removeClass("margin-left-50");
  211. jQuery('.sidebar-collapse i').removeClass(iconRight);
  212. jQuery('.sidebar-collapse i').addClass(iconLeft);
  213. /* Add placeholder from Search Bar */
  214. jQuery('.search').attr('placeholder', "Search");
  215. collapsed = false;
  216. $.cookie('mini_sidebar', '0');
  217. }
  218. else {
  219. /* For Navbar */
  220. jQuery('.navbar-brand').addClass("mini-menu");
  221. /* For sidebar */
  222. jQuery('#sidebar').addClass("mini-menu");
  223. jQuery('#main-content').addClass("margin-left-50");
  224. jQuery('.sidebar-collapse i').removeClass(iconLeft);
  225. jQuery('.sidebar-collapse i').addClass(iconRight);
  226. /* Remove placeholder from Search Bar */
  227. jQuery('.search').attr('placeholder', '');
  228. collapsed = true;
  229. $.cookie('mini_sidebar', '1');
  230. }
  231. $("#main-content").on('resize', function (e) {
  232. e.stopPropagation();
  233. });
  234. }
  235. });
  236. }
  237. /*-----------------------------------------------------------------------------------*/
  238. /* Handle Fixed Sidebar on Mobile devices
  239. /*-----------------------------------------------------------------------------------*/
  240. var handleMobileSidebar = function () {
  241. var menu = $('.sidebar');
  242. if (menu.parent('.slimScrollDiv').size() === 1) { // destroy existing instance before updating the height
  243. menu.slimScroll({
  244. destroy: true
  245. });
  246. menu.removeAttr('style');
  247. $('#sidebar').removeAttr('style');
  248. }
  249. menu.slimScroll({
  250. size: '7px',
  251. color: '#a1b2bd',
  252. opacity: .3,
  253. height: "100%",
  254. allowPageScroll: false,
  255. disableFadeOut: false
  256. });
  257. }
  258. /*-----------------------------------------------------------------------------------*/
  259. /* Handle Fixed Sidebar
  260. /*-----------------------------------------------------------------------------------*/
  261. var handleFixedSidebar = function () {
  262. var menu = $('.sidebar-menu');
  263. if (menu.parent('.slimScrollDiv').size() === 1) { // destroy existing instance before updating the height
  264. menu.slimScroll({
  265. destroy: true
  266. });
  267. menu.removeAttr('style');
  268. $('#sidebar').removeAttr('style');
  269. }
  270. if ($('.sidebar-fixed').size() === 0) {
  271. handleSidebarAndContentHeight();
  272. return;
  273. }
  274. var viewport = getViewPort();
  275. if (viewport.width >= 992) {
  276. var sidebarHeight = $(window).height() - $('#header').height() + 1;
  277. menu.slimScroll({
  278. size: '7px',
  279. color: '#a1b2bd',
  280. opacity: .3,
  281. height: sidebarHeight,
  282. allowPageScroll: false,
  283. disableFadeOut: false
  284. });
  285. handleSidebarAndContentHeight();
  286. }
  287. }
  288. /*-----------------------------------------------------------------------------------*/
  289. /* Windows Resize function
  290. /*-----------------------------------------------------------------------------------*/
  291. jQuery(window).resize(function() {
  292. setTimeout(function () {
  293. checkLayout();
  294. handleSidebarAndContentHeight();
  295. responsiveSidebar();
  296. handleFixedSidebar();
  297. handleNavbarFixedTop();
  298. runResponsiveFunctions();
  299. }, 50); // wait 50ms until window resize finishes.
  300. });
  301. /*-----------------------------------------------------------------------------------*/
  302. /* Date Range Picker
  303. /*-----------------------------------------------------------------------------------*/
  304. var handleDateTimePickers = function () {
  305. $('#reportrange').daterangepicker(
  306. {
  307. startDate: moment().subtract('days', 29),
  308. endDate: moment(),
  309. minDate: '01/01/2012',
  310. maxDate: '12/31/2014',
  311. dateLimit: { days: 60 },
  312. showDropdowns: true,
  313. showWeekNumbers: true,
  314. timePicker: false,
  315. timePickerIncrement: 1,
  316. timePicker12Hour: true,
  317. ranges: {
  318. 'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)],
  319. 'Last 30 Days': [moment().subtract('days', 29), moment()],
  320. 'This Month': [moment().startOf('month'), moment().endOf('month')]
  321. },
  322. opens: 'left',
  323. buttonClasses: ['btn btn-default'],
  324. applyClass: 'btn-small btn-primary',
  325. cancelClass: 'btn-small',
  326. format: 'MM/DD/YYYY',
  327. separator: ' to ',
  328. locale: {
  329. applyLabel: 'Submit',
  330. fromLabel: 'From',
  331. toLabel: 'To',
  332. customRangeLabel: 'Custom Range',
  333. daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'],
  334. monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  335. firstDay: 1
  336. }
  337. },
  338. function(start, end) {
  339. console.log("Callback has been called!");
  340. $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
  341. }
  342. );
  343. //Set the initial state of the picker label
  344. $('#reportrange span').html('Custom');
  345. }
  346. /*-----------------------------------------------------------------------------------*/
  347. /* Team View
  348. /*-----------------------------------------------------------------------------------*/
  349. var handleTeamView = function () {
  350. c();
  351. $(".team-status-toggle").click(function (y) {
  352. y.preventDefault();
  353. w(this);
  354. $(this).parent().toggleClass("open");
  355. var z = x(this);
  356. $(z).slideToggle(200, function () {
  357. $(this).toggleClass("open")
  358. })
  359. });
  360. $("body").click(function (z) {
  361. var y = z.target.className.split(" ");
  362. if ($.inArray("team-status", y) == -1 && $.inArray("team-status-toggle", y) == -1 && $(z.target).parents().index($(".team-status")) == -1 && $(z.target).parents(".team-status-toggle").length == 0) {
  363. w()
  364. }
  365. });
  366. $(".team-status #teamslider").each(function () {
  367. $(this).slimScrollHorizontal({
  368. width: "100%",
  369. alwaysVisible: true,
  370. color: "#fff",
  371. opacity: "0.5",
  372. size: "5px"
  373. })
  374. });
  375. var w = function (y) {
  376. $(".team-status").each(function () {
  377. var z = $(this);
  378. if (z.is(":visible")) {
  379. var A = x(y);
  380. if (A != ("#" + z.attr("id"))) {
  381. $(this).slideUp(200, function () {
  382. $(this).toggleClass("open");
  383. $(".team-status-toggle").each(function () {
  384. var B = x(this);
  385. if (B == ("#" + z.attr("id"))) {
  386. $(this).parent().removeClass("open")
  387. }
  388. })
  389. })
  390. }
  391. }
  392. })
  393. };
  394. var x = function (y) {
  395. var z = $(y).data("teamStatus");
  396. if (typeof z == "undefined") {
  397. z = "#team-status"
  398. }
  399. return z
  400. }
  401. }
  402. var c = function () {
  403. $(".team-status").each(function () {
  404. var x = $(this);
  405. x.css("position", "absolute").css("margin-top", "-1000px").show();
  406. var w = 0;
  407. $("ul li", this).each(function () {
  408. w += $(this).outerWidth(true) + 15
  409. });
  410. x.css("position", "relative").css("margin-top", "0").hide();
  411. $("ul", this).width(w)
  412. })
  413. };
  414. /*-----------------------------------------------------------------------------------*/
  415. /* Homepage tooltips
  416. /*-----------------------------------------------------------------------------------*/
  417. var handleHomePageTooltips = function () {
  418. //On Hover
  419. //Default tooltip (Top)
  420. $('.tip').tooltip();
  421. //Bottom tooltip
  422. $('.tip-bottom').tooltip({
  423. placement : 'bottom'
  424. });
  425. //Left tooltip
  426. $('.tip-left').tooltip({
  427. placement : 'left'
  428. });
  429. //Right tooltip
  430. $('.tip-right').tooltip({
  431. placement : 'right'
  432. });
  433. //On Focus
  434. //Default tooltip (Top)
  435. $('.tip-focus').tooltip({
  436. trigger: 'focus'
  437. });
  438. }
  439. /*-----------------------------------------------------------------------------------*/
  440. /* Box tools
  441. /*-----------------------------------------------------------------------------------*/
  442. var handleBoxTools = function () {
  443. //Collapse
  444. jQuery('.box .tools .collapse, .box .tools .expand').click(function () {
  445. var el = jQuery(this).parents(".box").children(".box-body");
  446. if (jQuery(this).hasClass("collapse")) {
  447. jQuery(this).removeClass("collapse").addClass("expand");
  448. var i = jQuery(this).children(".fa-chevron-up");
  449. i.removeClass("fa-chevron-up").addClass("fa-chevron-down");
  450. el.slideUp(200);
  451. } else {
  452. jQuery(this).removeClass("expand").addClass("collapse");
  453. var i = jQuery(this).children(".fa-chevron-down");
  454. i.removeClass("fa-chevron-down").addClass("fa-chevron-up");
  455. el.slideDown(200);
  456. }
  457. });
  458. /* Close */
  459. jQuery('.box .tools a.remove').click(function () {
  460. var removable = jQuery(this).parents(".box");
  461. if (removable.next().hasClass('box') || removable.prev().hasClass('box')) {
  462. jQuery(this).parents(".box").remove();
  463. } else {
  464. jQuery(this).parents(".box").parent().remove();
  465. }
  466. });
  467. /* Reload */
  468. jQuery('.box .tools a.reload').click(function () {
  469. var el = jQuery(this).parents(".box");
  470. App.blockUI(el);
  471. window.setTimeout(function () {
  472. App.unblockUI(el);
  473. }, 1000);
  474. });
  475. }
  476. /*-----------------------------------------------------------------------------------*/
  477. /* SlimScroll
  478. /*-----------------------------------------------------------------------------------*/
  479. var handleSlimScrolls = function () {
  480. if (!jQuery().slimScroll) {
  481. return;
  482. }
  483. $('.scroller').each(function () {
  484. $(this).slimScroll({
  485. size: '7px',
  486. color: '#a1b2bd',
  487. height: $(this).attr("data-height"),
  488. alwaysVisible: ($(this).attr("data-always-visible") == "1" ? true : false),
  489. railVisible: ($(this).attr("data-rail-visible") == "1" ? true : false),
  490. railOpacity: 0.1,
  491. disableFadeOut: true
  492. });
  493. });
  494. }
  495. /*-----------------------------------------------------------------------------------*/
  496. /* Bootbox alerts
  497. /*-----------------------------------------------------------------------------------*/
  498. var handleBootbox = function () {
  499. $(".basic-alert").click(function(){
  500. bootbox.alert("Hello World");
  501. });
  502. $(".confirm-dialog").click(function(){
  503. bootbox.confirm("Are you sure?", function(result){});
  504. });
  505. $(".multiple-buttons").click(function(){
  506. bootbox.dialog({
  507. message: "I am a custom dialog",
  508. title: "Custom title",
  509. buttons: {
  510. success: {
  511. label: "Success!",
  512. className: "btn-success",
  513. callback: function() {
  514. Example.show("great success");
  515. }
  516. },
  517. danger: {
  518. label: "Danger!",
  519. className: "btn-danger",
  520. callback: function() {
  521. Example.show("uh oh, look out!");
  522. }
  523. },
  524. main: {
  525. label: "Click ME!",
  526. className: "btn-primary",
  527. callback: function() {
  528. Example.show("Primary button");
  529. }
  530. }
  531. }
  532. });
  533. });
  534. $(".multiple-dialogs").click(function(){
  535. bootbox.alert("In 1 second a new modal will open");
  536. setTimeout(function() {
  537. bootbox.dialog({
  538. message: "Will you purchase this awesome theme",
  539. title: "Pop quiz",
  540. buttons: {
  541. success: {
  542. label: "Yes!",
  543. className: "btn-success",
  544. callback: function() {
  545. bootbox.alert("Congratulations! You made the right decision.", function(){
  546. $(".bootbox").modal("hide");
  547. });
  548. }
  549. },
  550. danger: {
  551. label: "No!",
  552. className: "btn-danger",
  553. callback: function() {
  554. bootbox.alert("Oops, we're sorry to hear that!", function(){
  555. $(".bootbox").modal("hide");
  556. });
  557. }
  558. },
  559. main: {
  560. label: "Click ME!",
  561. className: "btn-primary",
  562. callback: function() {
  563. bootbox.alert("Hello World", function(){
  564. $(".bootbox").modal("hide");
  565. });
  566. }
  567. }
  568. }
  569. });
  570. }, 1000);
  571. });
  572. $(".programmatic-close").click(function(){
  573. bootbox.alert("In 3 second this modal will close..");
  574. setTimeout(function() {
  575. $(".bootbox").modal("hide");
  576. }, 3000);
  577. });
  578. }
  579. /*-----------------------------------------------------------------------------------*/
  580. /* Popovers
  581. /*-----------------------------------------------------------------------------------*/
  582. /*var handlePopovers = function () {
  583. //Default (Right)
  584. $('.pop').popover();
  585. //Bottom
  586. $('.pop-bottom').popover({
  587. placement : 'bottom'
  588. });
  589. //Left
  590. $('.pop-left').popover({
  591. placement : 'left'
  592. });
  593. //Top
  594. $('.pop-top').popover({
  595. placement : 'top'
  596. });
  597. //Trigger hover
  598. $('.pop-hover').popover({
  599. trigger: 'hover'
  600. });
  601. }*/
  602. /*-----------------------------------------------------------------------------------*/
  603. /* Hubspot messenger
  604. /*-----------------------------------------------------------------------------------*/
  605. var handleMessenger = function () {
  606. //Normal
  607. $("#normal").click(function(){
  608. var mytheme = $('input[name=theme]:checked').val();
  609. var mypos = $('input[name=position]:checked').val();
  610. //Set theme
  611. Messenger.options = {
  612. extraClasses: 'messenger-fixed '+mypos,
  613. theme: mytheme
  614. }
  615. //Call
  616. Messenger().post({
  617. message:"This is a normal notification!",
  618. showCloseButton: true
  619. });
  620. });
  621. //Interactive
  622. $("#interactive").click(function(){
  623. var mytheme = $('input[name=theme]:checked').val();
  624. var mypos = $('input[name=position]:checked').val();
  625. //Set theme
  626. Messenger.options = {
  627. extraClasses: 'messenger-fixed '+mypos,
  628. theme: mytheme
  629. }
  630. var msg;
  631. msg = Messenger().post({
  632. message: 'Launching thermonuclear war...',
  633. type: 'info',
  634. actions: {
  635. cancel: {
  636. label: 'cancel launch',
  637. action: function() {
  638. return msg.update({
  639. message: 'Thermonuclear war averted',
  640. type: 'success',
  641. showCloseButton: true,
  642. actions: false
  643. });
  644. }
  645. }
  646. }
  647. });
  648. });
  649. //Timer
  650. $("#timer").click(function(){
  651. var mytheme = $('input[name=theme]:checked').val();
  652. var mypos = $('input[name=position]:checked').val();
  653. //Set theme
  654. Messenger.options = {
  655. extraClasses: 'messenger-fixed '+mypos,
  656. theme: mytheme
  657. }
  658. var i;
  659. i = 0;
  660. Messenger().run({
  661. errorMessage: 'Error destroying alien planet',
  662. successMessage: 'Alien planet destroyed!',
  663. showCloseButton: true,
  664. action: function(opts) {
  665. if (++i < 3) {
  666. return opts.error({
  667. status: 500,
  668. readyState: 0,
  669. responseText: 0
  670. });
  671. } else {
  672. return opts.success();
  673. }
  674. }
  675. });
  676. });
  677. //Prompts
  678. $("#prompts").click(function(){
  679. var mytheme = $('input[name=theme]:checked').val();
  680. var mypos = $('input[name=position]:checked').val();
  681. //Set theme
  682. Messenger.options = {
  683. extraClasses: 'messenger-fixed '+mypos,
  684. theme: mytheme
  685. }
  686. Messenger().run({
  687. successMessage: 'Data saved.',
  688. errorMessage: 'Error saving data',
  689. progressMessage: 'Saving data',
  690. showCloseButton: true,
  691. }, {
  692. url: 'http://www.example.com/data'
  693. });
  694. });
  695. }
  696. /*-----------------------------------------------------------------------------------*/
  697. /* Alerts
  698. /*-----------------------------------------------------------------------------------*/
  699. var handleAlerts = function () {
  700. $(".alert").alert();
  701. }
  702. /*-----------------------------------------------------------------------------------*/
  703. /* Magic Suggest
  704. /*-----------------------------------------------------------------------------------*/
  705. var handleMagicSuggest = function () {
  706. var jsonData = [];
  707. var cities = 'New York,Los Angeles,Chicago,Houston,Paris,Marseille,Toulouse,Lyon,Bordeaux,Philadelphia,Phoenix,San Antonio,San Diego,Dallas,San Jose,Jacksonville'.split(',');
  708. for(var i=0;i<cities.length;i++) jsonData.push({id:i,name:cities[i],status:i%2?'Already Visited':'Planned for visit',coolness:Math.floor(Math.random() * 10) + 1});
  709. var ms1 = $('#ms1').magicSuggest({
  710. data: jsonData,
  711. sortOrder: 'name',
  712. value: [0],
  713. selectionPosition: 'right',
  714. groupBy: 'status',
  715. maxDropHeight: 200
  716. });
  717. var ms2 = $('#ms2').magicSuggest({
  718. width: '80%',
  719. data: jsonData
  720. });
  721. var ms3 = $('#ms3').magicSuggest({
  722. selectionPosition: 'bottom',
  723. renderer: function(city){
  724. return '<div>' +
  725. '<div style="font-family: Arial; font-weight: bold">' + city.name + '</div>' +
  726. '<div><b>Cooooolness</b>: ' + city.coolness + '</div>' +
  727. '</div>';
  728. },
  729. minChars: 1,
  730. selectionStacked: true,
  731. data: jsonData
  732. });
  733. var ms4 = $('#ms4').magicSuggest({
  734. data: [{id:1,label:'one'}, {id:2,label:'two'}, {id:3,label:'three'}],
  735. displayField: 'label',
  736. value: [1,3]
  737. });
  738. var ms5 = $('#ms5').magicSuggest({
  739. width: '80%',
  740. data: 'marilyn@monroe.com,mother@teresa.com,john@kennedy.com,martin@luther.com,nelson@mandela.com,winston@churchill.com,bill@gates.com,muhammad@ali.com,mahatma@gandhi.com,margaret@thatcher.com,charles@gaulle.com,christopher@colombus.com,george@orwell.com,charles@darwin.com,elvis@presley.com,albert@einstein.com,paul@mccartney.com,queen@elizabeth.com,queen@victoria.com,john@keynes.com,mikhail@gorbachev.com,jawaharlal@nehru.com,leonardo@vinci.com,louis@pasteur.com,leo@tolstoy.com,pablo@picasso.com,vincent@gogh.com,franklin@roosevelt.com,john@paul.com,neil@armstrong.com,thomas@edison.com,rosa@parks.com,aung@kyi.com,lyndon@johnson.com,ludwig@beethoven.com,oprah@winfrey.com,indira@gandhi.com,eva@peron.com,benazir@bhutto.com,desmond@tutu.com,dalai@lama.com,walt@disney.com,peter@sellers.com,barack@obama.com,malcolm@x.com,richard@branson.com,jesse@owens.com,ernest@hemingway.com,john@lennon.com,henry@ford.com,haile@selassie.com,joseph@stalin.com,lord@baden.com,michael@jordon.com,george@bush.com,osama@laden.com,fidel@castro.com,oscar@wilde.com,coco@chanel.com,amelia@earhart.com,adolf@hitler.com,mary@magdalene.com,alfred@hitchcock.com,michael@jackson.com,mata@hari.com,emmeline@pankhurst.com,ronald@reagan.com,lionel@messi.com,babe@ruth.com,bob@geldof.com,leon@trotsky.com,roger@federer.com,sigmund@freud.com,woodrow@wilson.com,mao@zedong.com,katherine@hepburn.com,audrey@hepburn.com,david@beckham.com,tiger@woods.com,usain@bolt.com,bill@cosby.com,carl@lewis.com,prince@charles.com,jacqueline@onassis.com,billie@holiday.com,virginia@woolf.com,billie@king.com,kylie@minogue.com,anne@frank.com,emile@zatopek.com,lech@walesa.com,christiano@ronaldo.com,yoko@ono.com,julie@andrews.com,florence@nightingale.com,marie@curie.com,stephen@hawking.com,tim@lee.com,lady@gaga.com,lance@armstrong.com,jon@stewart.com,scarlett@johansson.com,larry@page.com,sergey@brin.com,roman@abramovich.com,rupert@murdoch.com,al@gore.com,sacha@baron.com,george@clooney.com,paul@krugman.com,jimmy@wales.com'
  741. });
  742. var ms6 = $('#ms6').magicSuggest({
  743. // will fetch data from options
  744. });
  745. var ms7 = $('#ms7').magicSuggest({
  746. data: jsonData,
  747. resultAsString: true,
  748. maxSelection: 1,
  749. maxSelectionRenderer: function(){}
  750. })
  751. }
  752. /*-----------------------------------------------------------------------------------*/
  753. /* Timeago
  754. /*-----------------------------------------------------------------------------------*/
  755. var handleTimeAgo = function () {
  756. jQuery(document).ready(function() {
  757. var curr_time = moment().format('YYYY-MM-DD HH:mm');
  758. var yesterday = moment().subtract('days', 1).format('MMM D, YYYY');
  759. $("#curr-time").html(curr_time);
  760. $("#curr-time").attr('title', curr_time);
  761. $("#curr-time").attr('data-original-title', curr_time);
  762. $("#yesterday").html(yesterday);
  763. $("#yesterday").attr('title', yesterday);
  764. $("#yesterday").attr('data-original-title', yesterday);
  765. jQuery("abbr.timeago").timeago();
  766. });
  767. }
  768. /*-----------------------------------------------------------------------------------*/
  769. /* Init Timeago
  770. /*-----------------------------------------------------------------------------------*/
  771. var initTimeAgo = function () {
  772. jQuery("abbr.timeago").timeago();
  773. }
  774. /*-----------------------------------------------------------------------------------*/
  775. /* Date & Color Picker
  776. /*-----------------------------------------------------------------------------------*/
  777. var handleDateColorpicker = function () {
  778. $(".datepicker").datepicker();
  779. $(".inlinepicker").datepicker({
  780. inline: true,
  781. showOtherMonths: true
  782. });
  783. $(".datepicker-fullscreen").pickadate();
  784. $(".timepicker-fullscreen").pickatime();
  785. //Color picker
  786. $('.colorpicker').colorpicker();
  787. var a = $("#color-pickers")[0].style;
  788. $("#colorpicker-event").colorpicker().on("changeColor", function (b) {
  789. a.backgroundColor = b.color.toHex()
  790. });
  791. }
  792. /*-----------------------------------------------------------------------------------*/
  793. /* Raty
  794. /*-----------------------------------------------------------------------------------*/
  795. var handleRaty = function () {
  796. $.fn.raty.defaults.path = 'js/jquery-raty/img';
  797. $('#score-demo').raty({ score: 3 });
  798. $('#number-demo').raty({ number: 10 });
  799. $('#readOnly-demo').raty({ readOnly: true, score: 2 });
  800. $('#halfShow-true-demo').raty({ score: 3.26 });
  801. $('#starHalf-demo').raty({
  802. path : 'js/jquery-raty/img',
  803. half : true,
  804. starOff : 'cookie-off.png',
  805. starOn : 'cookie-on.png',
  806. starHalf: 'cookie-half.png'
  807. });
  808. $('#star-off-and-star-on-demo').raty({
  809. path : 'js/jquery-raty/img',
  810. starOff: 'off.png',
  811. starOn : 'on.png'
  812. });
  813. $('#cancel-off-and-cancel-on-demo').raty({
  814. path : 'js/jquery-raty/img',
  815. cancel : true,
  816. cancelOff: 'cancel-custom-off.png',
  817. cancelOn : 'cancel-custom-on.png',
  818. starOn : 'star-on.png',
  819. starOff : 'star-off.png'
  820. });
  821. $('#size-demo').raty({
  822. path : 'js/jquery-raty/img',
  823. cancel : true,
  824. cancelOff: 'cancel-off-big.png',
  825. cancelOn : 'cancel-on-big.png',
  826. half : true,
  827. size : 24,
  828. starHalf : 'star-half-big.png',
  829. starOff : 'star-off-big.png',
  830. starOn : 'star-on-big.png'
  831. });
  832. $('#target-div-demo').raty({
  833. cancel: true,
  834. target: '#target-div-hint'
  835. });
  836. }
  837. /*-----------------------------------------------------------------------------------*/
  838. /* Stateful buttons
  839. /*-----------------------------------------------------------------------------------*/
  840. var handleStatefulButtons = function () {
  841. $(document).ready(function(){
  842. $("#btn-load").on("click",function(){
  843. var a=$(this);
  844. a.button("loading");
  845. setTimeout(function(){
  846. a.button("reset")}
  847. ,1500)}
  848. );
  849. $("#btn-load-complete").on("click",function(){
  850. var a=$(this);
  851. a.button("loading");
  852. setTimeout(function(){
  853. a.button("complete")}
  854. ,1500)}
  855. )}
  856. );
  857. }
  858. /*-----------------------------------------------------------------------------------*/
  859. /* Toggle buttons
  860. /*-----------------------------------------------------------------------------------*/
  861. var handleToggle = function () {
  862. $('.radio1').on('switch-change', function () {
  863. $('.radio1').bootstrapSwitch('toggleRadioState');
  864. });
  865. // or
  866. $('.radio1').on('switch-change', function () {
  867. $('.radio1').bootstrapSwitch('toggleRadioStateAllowUncheck');
  868. });
  869. // or
  870. $('.radio1').on('switch-change', function () {
  871. $('.radio1').bootstrapSwitch('toggleRadioStateAllowUncheck', false);
  872. });
  873. }
  874. /*-----------------------------------------------------------------------------------*/
  875. /* jQuery UI Sliders
  876. /*-----------------------------------------------------------------------------------*/
  877. var handleSliders = function () {
  878. function repositionTooltip( e, ui ){$
  879. var div = $(ui.handle).data("bs.tooltip").$tip[0];
  880. var pos = $.extend({}, $(ui.handle).offset(), { width: $(ui.handle).get(0).offsetWidth,
  881. height: $(ui.handle).get(0).offsetHeight
  882. });
  883. var actualWidth = div.offsetWidth;
  884. tp = {left: pos.left + pos.width / 2 - actualWidth / 2}
  885. $(div).offset(tp);
  886. $(div).find(".tooltip-inner").text( ui.value );
  887. }
  888. $("#slider").slider({ value: 15, slide: repositionTooltip, stop: repositionTooltip });
  889. $("#slider .ui-slider-handle:first").tooltip( {title: $("#slider").slider("value"), trigger: "manual"}).tooltip("show");
  890. $("#slider-default").slider();
  891. $("#slider-range").slider({
  892. range:true,min:0,max:500,values:[75,300]
  893. });
  894. $("#slider-range-min").slider({
  895. range:"min",value:37,min:1,max:700,slide:function(a,b){
  896. $("#slider-range-min-amount").text("$"+b.value)}
  897. });
  898. $("#slider-range-max").slider({
  899. range:"max",min:1,max:700,value:300,slide:function(a,b){
  900. $("#slider-range-max-amount").text("$"+b.value)}
  901. });
  902. $("#slider-vertical-multiple > span").each(function(){
  903. var a=parseInt($(this).text(),10);
  904. $(this).empty().slider({
  905. value:a,range:"min",animate:true,orientation:"vertical"}
  906. )}
  907. );
  908. $("#slider-vertical-range-min").slider({
  909. range:"min",value:400,min:1,max:600,orientation:"vertical"
  910. });
  911. $("#slider-horizontal-range-min").slider({
  912. range:"min",value:600,min:1,max:1000
  913. });
  914. }
  915. /*-----------------------------------------------------------------------------------*/
  916. /* jQuery UI Progress
  917. /*-----------------------------------------------------------------------------------*/
  918. var handleProgress = function () {
  919. $(document).ready(function(){
  920. jQuery.fn.anim_progressbar = function (aOptions) {
  921. // def values
  922. var iCms = 1000;
  923. var iMms = 60 * iCms;
  924. var iHms = 3600 * iCms;
  925. var iDms = 24 * 3600 * iCms;
  926. // def options
  927. var aDefOpts = {
  928. start: new Date(), // now
  929. finish: new Date().setTime(new Date().getTime() + 60 * iCms), // now + 60 sec
  930. interval: 100
  931. }
  932. var aOpts = jQuery.extend(aDefOpts, aOptions);
  933. var vPb = this;
  934. // each progress bar
  935. return this.each(
  936. function() {
  937. var iDuration = aOpts.finish - aOpts.start;
  938. // calling original progressbar
  939. $(vPb).children('.pbar').progressbar();
  940. // looping process
  941. var vInterval = setInterval(
  942. function(){
  943. var iLeftMs = aOpts.finish - new Date(); // left time in MS
  944. var iElapsedMs = new Date() - aOpts.start, // elapsed time in MS
  945. iDays = parseInt(iLeftMs / iDms), // elapsed days
  946. iHours = parseInt((iLeftMs - (iDays * iDms)) / iHms), // elapsed hours
  947. iMin = parseInt((iLeftMs - (iDays * iDms) - (iHours * iHms)) / iMms), // elapsed minutes
  948. iSec = parseInt((iLeftMs - (iDays * iDms) - (iMin * iMms) - (iHours * iHms)) / iCms), // elapsed seconds
  949. iPerc = (iElapsedMs > 0) ? iElapsedMs / iDuration * 100 : 0; // percentages
  950. // display current positions and progress
  951. $(vPb).children('.percent').html('<b>'+iPerc.toFixed(1)+'%</b>');
  952. $(vPb).children('.elapsed').html(iDays+' day '+iHours+' hr : '+iMin+' min : '+iSec+' sec remaining</b>');
  953. $(vPb).children('.pbar').children('.ui-progressbar-value').css('width', iPerc+'%');
  954. // in case of Finish
  955. if (iPerc >= 100) {
  956. clearInterval(vInterval);
  957. $(vPb).children('.percent').html('<b>100%</b>');
  958. $(vPb).children('.elapsed').html('Completed');
  959. }
  960. } ,aOpts.interval
  961. );
  962. }
  963. );
  964. }
  965. // default mode
  966. $('#progress1').anim_progressbar();
  967. // from second #5 till 15
  968. var iNow = new Date().setTime(new Date().getTime() + 5 * 1000); // now plus 5 secs
  969. var iEnd = new Date().setTime(new Date().getTime() + 15 * 1000); // now plus 15 secs
  970. $('#progress2').anim_progressbar({start: iNow, finish: iEnd, interval: 100});
  971. // we will just set interval of updating to 1 sec
  972. $('#progress3').anim_progressbar({interval: 1000});
  973. });
  974. }
  975. /*-----------------------------------------------------------------------------------*/
  976. /* jQuery Knob
  977. /*-----------------------------------------------------------------------------------*/
  978. var handleKnobs = function () {
  979. $(".knob").knob({
  980. change : function (value) {
  981. //console.log("change : " + value);
  982. },
  983. release : function (value) {
  984. //console.log(this.$.attr('value'));
  985. console.log("release : " + value);
  986. },
  987. cancel : function () {
  988. console.log("cancel : ", this);
  989. },
  990. draw : function () {
  991. // "tron" case
  992. if(this.$.data('skin') == 'tron') {
  993. var a = this.angle(this.cv) // Angle
  994. , sa = this.startAngle // Previous start angle
  995. , sat = this.startAngle // Start angle
  996. , ea // Previous end angle
  997. , eat = sat + a // End angle
  998. , r = 1;
  999. this.g.lineWidth = this.lineWidth;
  1000. this.o.cursor
  1001. && (sat = eat - 0.3)
  1002. && (eat = eat + 0.3);
  1003. if (this.o.displayPrevious) {
  1004. ea = this.startAngle + this.angle(this.v);
  1005. this.o.cursor
  1006. && (sa = ea - 0.3)
  1007. && (ea = ea + 0.3);
  1008. this.g.beginPath();
  1009. this.g.strokeStyle = this.pColor;
  1010. this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sa, ea, false);
  1011. this.g.stroke();
  1012. }
  1013. this.g.beginPath();
  1014. this.g.strokeStyle = r ? this.o.fgColor : this.fgColor ;
  1015. this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sat, eat, false);
  1016. this.g.stroke();
  1017. this.g.lineWidth = 2;
  1018. this.g.beginPath();
  1019. this.g.strokeStyle = this.o.fgColor;
  1020. this.g.arc( this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false);
  1021. this.g.stroke();
  1022. return false;
  1023. }
  1024. }
  1025. });
  1026. }
  1027. /*-----------------------------------------------------------------------------------*/
  1028. /* Custom tabs
  1029. /*-----------------------------------------------------------------------------------*/
  1030. var handleCustomTabs = function () {
  1031. var adjustMinHeight = function (y) {
  1032. $(y).each(function () {
  1033. var A = $($($(this).attr("href")));
  1034. var z = $(this).parent().parent();
  1035. if (z.height() > A.height()) {
  1036. A.css("min-height", z.height())
  1037. }
  1038. })
  1039. };
  1040. $("body").on("click", '.nav.nav-tabs.tabs-left a[data-toggle="tab"], .nav.nav-tabs.tabs-right a[data-toggle="tab"]', function () {
  1041. adjustMinHeight($(this))
  1042. });
  1043. adjustMinHeight('.nav.nav-tabs.tabs-left > li.active > a[data-toggle="tab"], .nav.nav-tabs.tabs-right > li.active > a[data-toggle="tab"]');
  1044. if (location.hash) {
  1045. var w = location.hash.substr(1);
  1046. $('a[href="#' + w + '"]').click()
  1047. }
  1048. }
  1049. /*-----------------------------------------------------------------------------------*/
  1050. /* Fuel UX Tree
  1051. /*-----------------------------------------------------------------------------------*/
  1052. var handleTree = function () {
  1053. $('#tree1').admin_tree({
  1054. dataSource: treeDataSource ,
  1055. multiSelect:true,
  1056. loadingHTML:'<div class="tree-loading"><i class="fa fa-spinner fa-2x fa-spin"></i></div>',
  1057. 'open-icon' : 'fa-minus',
  1058. 'close-icon' : 'fa-plus',
  1059. 'selectable' : true,
  1060. 'selected-icon' : 'fa-check',
  1061. 'unselected-icon' : 'fa-times'
  1062. });
  1063. $('#tree3').admin_tree({
  1064. dataSource: treeDataSource3 ,
  1065. multiSelect:true,
  1066. loadingHTML:'<div class="tree-loading"><i class="fa fa-spinner fa-2x fa-spin"></i></div>',
  1067. 'open-icon' : 'fa-minus-square',
  1068. 'close-icon' : 'fa-plus-square',
  1069. 'selectable' : true,
  1070. 'selected-icon' : 'fa-check',
  1071. 'unselected-icon' : 'fa-times'
  1072. });
  1073. $('#tree2').admin_tree({
  1074. dataSource: treeDataSource2 ,
  1075. loadingHTML:'<div class="tree-loading"><i class="fa fa-spinner fa-2x fa-spin"></i></div>',
  1076. 'open-icon' : 'fa-folder-open',
  1077. 'close-icon' : 'fa-folder',
  1078. 'selectable' : false,
  1079. 'selected-icon' : null,
  1080. 'unselected-icon' : null
  1081. });
  1082. //To add font awesome support
  1083. $('.tree').find('[class*="fa-"]').addClass("fa");
  1084. }
  1085. /*-----------------------------------------------------------------------------------*/
  1086. /* Nestable Lists
  1087. /*-----------------------------------------------------------------------------------*/
  1088. var handleNestableLists = function () {
  1089. var updateOutput = function(e)
  1090. {
  1091. var list = e.length ? e : $(e.target),
  1092. output = list.data('output');
  1093. if (window.JSON) {
  1094. output.val(window.JSON.stringify(list.nestable('serialize')));//, null, 2));
  1095. } else {
  1096. output.val('JSON browser support required for this demo.');
  1097. }
  1098. };
  1099. // activate Nestable for list 1
  1100. $('#nestable').nestable({
  1101. group: 1
  1102. })
  1103. .on('change', updateOutput);
  1104. // activate Nestable for list 2
  1105. $('#nestable2').nestable({
  1106. group: 1
  1107. })
  1108. .on('change', updateOutput);
  1109. // output initial serialised data
  1110. updateOutput($('#nestable').data('output', $('#nestable-output')));
  1111. updateOutput($('#nestable2').data('output', $('#nestable2-output')));
  1112. $('#nestable-menu').on('click', function(e)
  1113. {
  1114. var target = $(e.target),
  1115. action = target.data('action');
  1116. if (action === 'expand-all') {
  1117. $('.dd').nestable('expandAll');
  1118. }
  1119. if (action === 'collapse-all') {
  1120. $('.dd').nestable('collapseAll');
  1121. }
  1122. });
  1123. $('#nestable3').nestable();
  1124. }
  1125. /*-----------------------------------------------------------------------------------*/
  1126. /* Table Cloth
  1127. /*-----------------------------------------------------------------------------------*/
  1128. var handleTablecloth = function () {
  1129. $("#example-dark").tablecloth({
  1130. theme: "dark"
  1131. });
  1132. $("#example-paper").tablecloth({
  1133. theme:"paper",
  1134. striped: true
  1135. });
  1136. $("#example-stats").tablecloth({
  1137. theme:"stats",
  1138. sortable:true,
  1139. condensed:true,
  1140. striped:true,
  1141. clean:true
  1142. });
  1143. }
  1144. /*-----------------------------------------------------------------------------------*/
  1145. /* Data Tables
  1146. /*-----------------------------------------------------------------------------------*/
  1147. var handleDataTables = function () {
  1148. $('#datatable1').dataTable({
  1149. "sPaginationType": "bs_full"
  1150. });
  1151. $('#datatable2').dataTable({
  1152. "sPaginationType": "bs_full",
  1153. sDom: "<'row'<'dataTables_header clearfix'<'col-md-4'l><'col-md-8'Tf>r>>t<'row'<'dataTables_footer clearfix'<'col-md-6'i><'col-md-6'p>>>",
  1154. oTableTools: {
  1155. aButtons: ["copy", "print", "csv", "xls", "pdf"],
  1156. sSwfPath: "js/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
  1157. }
  1158. });
  1159. $('.datatable').each(function(){
  1160. var datatable = $(this);
  1161. // SEARCH - Add the placeholder for Search and Turn this into in-line form control
  1162. var search_input = datatable.closest('.dataTables_wrapper').find('div[id$=_filter] input');
  1163. //search_input.attr('placeholder', 'Search');
  1164. search_input.addClass('form-control input-sm');
  1165. // LENGTH - Inline-Form control
  1166. var length_sel = datatable.closest('.dataTables_wrapper').find('div[id$=_length] select');
  1167. length_sel.addClass('form-control input-sm');
  1168. });
  1169. }
  1170. /*-----------------------------------------------------------------------------------*/
  1171. /* jqGrid
  1172. /*-----------------------------------------------------------------------------------*/
  1173. var handleJqgrid = function () {
  1174. var grid_data =
  1175. [
  1176. {id:"1",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1177. {id:"2",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1178. {id:"3",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1179. {id:"4",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1180. {id:"5",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1181. {id:"6",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1182. {id:"7",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1183. {id:"8",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1184. {id:"9",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1185. {id:"10",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1186. {id:"11",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1187. {id:"12",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1188. {id:"13",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1189. {id:"14",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1190. {id:"15",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1191. {id:"16",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1192. {id:"17",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1193. {id:"18",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1194. {id:"19",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1195. {id:"20",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1196. {id:"21",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1197. {id:"22",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1198. {id:"23",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1199. {id:"24",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"},
  1200. {id:"25",invdate:"2007-12-03",name:"Client1",amount:"1000.00",tax:"140.00",total:"1000.00", note:"This is a note"}
  1201. ];
  1202. jQuery("#rowed3").jqGrid({
  1203. data: grid_data,
  1204. datatype: "local",
  1205. height: 250,
  1206. colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
  1207. colModel: [{
  1208. name: 'id',
  1209. index: 'id',
  1210. width: 55
  1211. }, {
  1212. name: 'invdate',
  1213. index: 'invdate',
  1214. width: 90,
  1215. editable: true
  1216. }, {
  1217. name: 'name',
  1218. index: 'name',
  1219. width: 100,
  1220. editable: true
  1221. }, {
  1222. name: 'amount',
  1223. index: 'amount',
  1224. width: 80,
  1225. align: "right",
  1226. editable: true
  1227. }, {
  1228. name: 'tax',
  1229. index: 'tax',
  1230. width: 80,
  1231. align: "right",
  1232. editable: true
  1233. }, {
  1234. name: 'total',
  1235. index: 'total',
  1236. width: 80,
  1237. align: "right",
  1238. editable: true
  1239. }, {
  1240. name: 'note',
  1241. index: 'note',
  1242. width: 150,
  1243. sortable: false,
  1244. editable: true
  1245. }],
  1246. rowNum: 10,
  1247. rowList: [10, 20, 30],
  1248. pager: '#prowed3',
  1249. sortname: 'id',
  1250. viewrecords: true,
  1251. sortorder: "asc",
  1252. editurl: "server.html",
  1253. caption: "Inline navigator",
  1254. autowidth: true
  1255. });
  1256. jQuery("#rowed3").jqGrid('navGrid', "#prowed3", {
  1257. edit: false,
  1258. add: false,
  1259. del: false
  1260. });
  1261. jQuery("#rowed3").jqGrid('inlineNav', "#prowed3");
  1262. /* Add tooltips */
  1263. $('.navtable .ui-pg-button').tooltip({container:'body'});
  1264. }
  1265. /*-----------------------------------------------------------------------------------*/
  1266. /* Typeahead
  1267. /*-----------------------------------------------------------------------------------*/
  1268. var handleTypeahead = function () {
  1269. $('#autocomplete-example').typeahead({
  1270. name: 'countries',
  1271. local: ["red", "blue", "green", "yellow", "brown", "black"]
  1272. });
  1273. }
  1274. /*-----------------------------------------------------------------------------------*/
  1275. /* Autosize
  1276. /*-----------------------------------------------------------------------------------*/
  1277. var handleAutosize = function () {
  1278. $('textarea.autosize').autosize();
  1279. $('textarea.autosize').addClass('textarea-transition');
  1280. }
  1281. /*-----------------------------------------------------------------------------------*/
  1282. /* jquery Counatble
  1283. /*-----------------------------------------------------------------------------------*/
  1284. var handleCountable = function () {
  1285. $('.countable').simplyCountable();
  1286. }
  1287. /*-----------------------------------------------------------------------------------*/
  1288. /* Select2
  1289. /*-----------------------------------------------------------------------------------*/
  1290. var handleSelect2 = function () {
  1291. function movieFormatResult(movie) {
  1292. var markup = "<table class='movie-result'><tr>";
  1293. if (movie.posters !== undefined && movie.posters.thumbnail !== undefined) {
  1294. markup += "<td class='movie-image'><img src='" + movie.posters.thumbnail + "'/></td>";
  1295. }
  1296. markup += "<td class='movie-info'><div class='movie-title'>" + movie.title + "</div>";
  1297. if (movie.critics_consensus !== undefined) {
  1298. markup += "<div class='movie-synopsis'>" + movie.critics_consensus + "</div>";
  1299. }
  1300. else if (movie.synopsis !== undefined) {
  1301. markup += "<div class='movie-synopsis'>" + movie.synopsis + "</div>";
  1302. }
  1303. markup += "</td></tr></table>"
  1304. return markup;
  1305. }
  1306. function movieFormatSelection(movie) {
  1307. return movie.title;
  1308. }
  1309. /* Basic */
  1310. $("#e1").select2();
  1311. /* Multi-Value Select Boxes */
  1312. $("#e2").select2();
  1313. /* With Placeholders */
  1314. $("#e3").select2({
  1315. placeholder: "Select a State",
  1316. allowClear: true
  1317. });
  1318. /* With Placeholders */
  1319. $("#e4").select2({
  1320. placeholder: "Select a State"
  1321. });
  1322. /* Minimum Input */
  1323. $("#e5").select2({
  1324. placeholder: "Select 2 characters",
  1325. minimumInputLength: 2
  1326. });
  1327. /* Maximum Selection Size */
  1328. $("#e6").select2({
  1329. placeholder: "Select a maximum of 3 states",
  1330. maximumSelectionSize: 3
  1331. });
  1332. /* Loading Remote Data */
  1333. $("#e7").select2({
  1334. placeholder: "Search for a movie",
  1335. minimumInputLength: 1,
  1336. ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
  1337. url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
  1338. dataType: 'jsonp',
  1339. data: function (term, page) {
  1340. return {
  1341. q: term, // search term
  1342. page_limit: 10,
  1343. apikey: "uekzdmffsrmqzwdtcgmc5yu9" //please do not copy API. Use your own. Copying will be treated as a violation - Cloud Admin Author
  1344. };
  1345. },
  1346. results: function (data, page) { // parse the results into the format expected by Select2.
  1347. // since we are using custom formatting functions we do not need to alter remote JSON data
  1348. return {results: data.movies};
  1349. }
  1350. },
  1351. initSelection: function(element, callback) {
  1352. // the input tag has a value attribute preloaded that points to a preselected movie's id
  1353. // this function resolves that id attribute to an object that select2 can render
  1354. // using its formatResult renderer - that way the movie name is shown preselected
  1355. var id=$(element).val();
  1356. if (id!=="") {
  1357. $.ajax("http://api.rottentomatoes.com/api/public/v1.0/movies/"+id+".json", {
  1358. data: {
  1359. apikey: "uekzdmffsrmqzwdtcgmc5yu9" //please do not copy API. Use your own. Copying will be treated as a violation - Cloud Admin Author
  1360. },
  1361. dataType: "jsonp"
  1362. }).done(function(data) { callback(data); });
  1363. }
  1364. },
  1365. formatResult: movieFormatResult, // omitted for brevity, see the source of this page
  1366. formatSelection: movieFormatSelection, // omitted for brevity, see the source of this page
  1367. dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
  1368. escapeMarkup: function (m) { return m; } // we do not want to escape markup since we are displaying html in results
  1369. });
  1370. /* Tagging Support */
  1371. $("#e8").select2({
  1372. tags:["red", "green", "blue"]
  1373. });
  1374. }
  1375. /*-----------------------------------------------------------------------------------*/
  1376. /* Uniform
  1377. /*-----------------------------------------------------------------------------------*/
  1378. var handleUniform = function () {
  1379. $(".uniform").uniform();
  1380. }
  1381. /*-----------------------------------------------------------------------------------*/
  1382. /* All Checkboxes
  1383. /*-----------------------------------------------------------------------------------*/
  1384. var handleAllUniform = function () {
  1385. $("select, input[type='checkbox']").uniform();
  1386. }
  1387. /*-----------------------------------------------------------------------------------*/
  1388. /* BT Wysiwyg
  1389. /*-----------------------------------------------------------------------------------*/
  1390. var handleWysiwyg = function () {
  1391. /* Init Bootstrap WYSIWYG */
  1392. function initToolbarBootstrapBindings() {
  1393. var fonts = ['Serif', 'Sans', 'Arial', 'Arial Black', 'Courier',
  1394. 'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande', 'Lucida Sans', 'Tahoma', 'Times',
  1395. 'Times New Roman', 'Verdana'],
  1396. fontTarget = $('[title=Font]').siblings('.dropdown-menu');
  1397. $.each(fonts, function (idx, fontName) {
  1398. fontTarget.append($('<li><a data-edit="fontName ' + fontName +'" style="font-family:\''+ fontName +'\'">'+fontName + '</a></li>'));
  1399. });
  1400. $('a[title]').tooltip({container:'body'});
  1401. $('.dropdown-menu input').click(function() {return false;})
  1402. .change(function () {$(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');})
  1403. .keydown('esc', function () {this.value='';$(this).change();});
  1404. $('[data-role=magic-overlay]').each(function () {
  1405. var overlay = $(this), target = $(overlay.data('target'));
  1406. overlay.css('opacity', 0).css('position', 'absolute').offset(target.offset()).width(target.outerWidth()).height(target.outerHeight());
  1407. });
  1408. if ("onwebkitspeechchange" in document.createElement("input")) {
  1409. var editorOffset = $('#editor').offset();
  1410. $('#voiceBtn').css('position','absolute').offset({top: editorOffset.top, left: editorOffset.left+$('#editor').innerWidth()-35});
  1411. } else {
  1412. $('#voiceBtn').hide();
  1413. }
  1414. };
  1415. function showErrorAlert (reason, detail) {
  1416. var msg='';
  1417. if (reason==='unsupported-file-type') { msg = "Unsupported format " +detail; }
  1418. else {
  1419. console.log("error uploading file", reason, detail);
  1420. }
  1421. $('<div class="alert"> <button type="button" class="close" data-dismiss="alert">&times;</button>'+
  1422. '<strong>File upload error</strong> '+msg+' </div>').prependTo('#alerts');
  1423. };
  1424. initToolbarBootstrapBindings();
  1425. $('#editor').wysiwyg({ fileUploadError: showErrorAlert} );
  1426. /* Disable auto-inline */
  1427. CKEDITOR.disableAutoInline = true;
  1428. }
  1429. /*-----------------------------------------------------------------------------------*/
  1430. /* Dropzone
  1431. /*-----------------------------------------------------------------------------------*/
  1432. var handleDropzone = function () {
  1433. try {
  1434. $(".dropzone").dropzone({
  1435. paramName: "file", // The name that will be used to transfer the file
  1436. maxFilesize: 0.5, // MB
  1437. addRemoveLinks : true,
  1438. dictResponseError: 'Error while uploading file!',
  1439. //change the previewTemplate to use Bootstrap progress bars
  1440. previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"progress progress-sm progress-striped active\"><div class=\"progress-bar progress-bar-success\" data-dz-uploadprogress></div></div>\n <div class=\"dz-success-mark\"><span></span></div>\n <div class=\"dz-error-mark\"><span></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>"
  1441. });
  1442. } catch(e) {
  1443. alert('Dropzone.js does not support older browsers!');
  1444. }
  1445. }
  1446. /*-----------------------------------------------------------------------------------*/
  1447. /* XCharts
  1448. /*-----------------------------------------------------------------------------------*/
  1449. var handleXcharts = function () {
  1450. //Dynamic Chart
  1451. function chart1() {
  1452. var data = [{"xScale":"ordinal","comp":[],"main":[{"className":".main.l1","data":[{"y":15,"x":"2012-11-19T00:00:00"},{"y":11,"x":"2012-11-20T00:00:00"},{"y":8,"x":"2012-11-21T00:00:00"},{"y":10,"x":"2012-11-22T00:00:00"},{"y":1,"x":"2012-11-23T00:00:00"},{"y":6,"x":"2012-11-24T00:00:00"},{"y":8,"x":"2012-11-25T00:00:00"}]},{"className":".main.l2","data":[{"y":29,"x":"2012-11-19T00:00:00"},{"y":33,"x":"2012-11-20T00:00:00"},{"y":13,"x":"2012-11-21T00:00:00"},{"y":16,"x":"2012-11-22T00:00:00"},{"y":7,"x":"2012-11-23T00:00:00"},{"y":18,"x":"2012-11-24T00:00:00"},{"y":8,"x":"2012-11-25T00:00:00"}]}],"type":"line-dotted","yScale":"linear"},{"xScale":"ordinal","comp":[],"main":[{"className":".main.l1","data":[{"y":12,"x":"2012-11-19T00:00:00"},{"y":18,"x":"2012-11-20T00:00:00"},{"y":8,"x":"2012-11-21T00:00:00"},{"y":7,"x":"2012-11-22T00:00:00"},{"y":6,"x":"2012-11-23T00:00:00"},{"y":12,"x":"2012-11-24T00:00:00"},{"y":8,"x":"2012-11-25T00:00:00"}]},{"className":".main.l2","data":[{"y":29,"x":"2012-11-19T00:00:00"},{"y":33,"x":"2012-11-20T00:00:00"},{"y":13,"x":"2012-11-21T00:00:00"},{"y":16,"x":"2012-11-22T00:00:00"},{"y":7,"x":"2012-11-23T00:00:00"},{"y":18,"x":"2012-11-24T00:00:00"},{"y":8,"x":"2012-11-25T00:00:00"}]}],"type":"cumulative","yScale":"linear"},{"xScale":"ordinal","comp":[],"main":[{"className":".main.l1","data":[{"y":12,"x":"2012-11-19T00:00:00"},{"y":18,"x":"2012-11-20T00:00:00"},{"y":8,"x":"2012-11-21T00:00:00"},{"y":7,"x":"2012-11-22T00:00:00"},{"y":6,"x":"2012-11-23T00:00:00"},{"y":12,"x":"2012-11-24T00:00:00"},{"y":8,"x":"2012-11-25T00:00:00"}]},{"className":".main.l2","data":[{"y":29,"x":"2012-11-19T00:00:00"},{"y":33,"x":"2012-11-20T00:00:00"},{"y":13,"x":"2012-11-21T00:00:00"},{"y":16,"x":"2012-11-22T00:00:00"},{"y":7,"x":"2012-11-23T00:00:00"},{"y":18,"x":"2012-11-24T00:00:00"},{"y":8,"x":"2012-11-25T00:00:00"}]}],"type":"bar","yScale":"linear"}];
  1453. var order = [0, 1, 0, 2],
  1454. i = 0,
  1455. xFormat = d3.time.format('%A'),
  1456. chart = new xChart('line-dotted', data[order[i]], '#chart1', {
  1457. axisPaddingTop: 5,
  1458. dataFormatX: function (x) {
  1459. return new Date(x);
  1460. },
  1461. tickFormatX: function (x) {
  1462. return xFormat(x);
  1463. },
  1464. timing: 1250
  1465. }),
  1466. rotateTimer,
  1467. toggles = d3.selectAll('.multi button'),
  1468. t = 3500;
  1469. function updateChart(i) {
  1470. var d = data[i];
  1471. chart.setData(d);
  1472. toggles.classed('toggled', function () {
  1473. return (d3.select(this).attr('data-type') === d.type);
  1474. });
  1475. return d;
  1476. }
  1477. toggles.on('click', function (d, i) {
  1478. clearTimeout(rotateTimer);
  1479. updateChart(i);
  1480. });
  1481. function rotateChart() {
  1482. i += 1;
  1483. i = (i >= order.length) ? 0 : i;
  1484. var d = updateChart(order[i]);
  1485. rotateTimer = setTimeout(rotateChart, t);
  1486. }
  1487. rotateTimer = setTimeout(rotateChart, t);
  1488. }
  1489. //Time-Series Line
  1490. function chart2() {
  1491. var data = {
  1492. "xScale": "time",
  1493. "yScale": "linear",
  1494. "type": "line",
  1495. "main": [
  1496. {
  1497. "className": ".pizza",
  1498. "data": [
  1499. {
  1500. "x": "2012-11-05",
  1501. "y": 1
  1502. },
  1503. {
  1504. "x": "2012-11-06",
  1505. "y": 6
  1506. },
  1507. {
  1508. "x": "2012-11-07",
  1509. "y": 13
  1510. },
  1511. {
  1512. "x": "2012-11-08",
  1513. "y": -3
  1514. },
  1515. {
  1516. "x": "2012-11-09",
  1517. "y": -4
  1518. },
  1519. {
  1520. "x": "2012-11-10",
  1521. "y": 9
  1522. },
  1523. {
  1524. "x": "2012-11-11",
  1525. "y": 6
  1526. }
  1527. ]
  1528. }
  1529. ]
  1530. };
  1531. var opts = {
  1532. "dataFormatX": function (x) { return d3.time.format('%Y-%m-%d').parse(x); },
  1533. "tickFormatX": function (x) { return d3.time.format('%A')(x); }
  1534. };
  1535. var myChart = new xChart('line', data, '#chart2', opts);
  1536. }
  1537. function chart3() {
  1538. var tt = document.createElement('div'),
  1539. leftOffset = -(~~$('html').css('padding-left').replace('px', '') + ~~$('body').css('margin-left').replace('px', '')),
  1540. topOffset = -32;
  1541. tt.className = 'ex-tooltip';
  1542. document.body.appendChild(tt);
  1543. var data = {
  1544. "xScale": "time",
  1545. "yScale": "linear",
  1546. "main": [
  1547. {
  1548. "className": ".pizza",
  1549. "data": [
  1550. {
  1551. "x": "2012-11-05",
  1552. "y": 6
  1553. },
  1554. {
  1555. "x": "2012-11-06",
  1556. "y": 6
  1557. },
  1558. {
  1559. "x": "2012-11-07",
  1560. "y": 8
  1561. },
  1562. {
  1563. "x": "2012-11-08",
  1564. "y": 3
  1565. },
  1566. {
  1567. "x": "2012-11-09",
  1568. "y": 4
  1569. },
  1570. {
  1571. "x": "2012-11-10",
  1572. "y": 9
  1573. },
  1574. {
  1575. "x": "2012-11-11",
  1576. "y": 6
  1577. }
  1578. ]
  1579. }
  1580. ]
  1581. };
  1582. var opts = {
  1583. "dataFormatX": function (x) { return d3.time.format('%Y-%m-%d').parse(x); },
  1584. "tickFormatX": function (x) { return d3.time.format('%A')(x); },
  1585. "mouseover": function (d, i) {
  1586. var pos = $(this).offset();
  1587. $(tt).text(d3.time.format('%A')(d.x) + ': ' + d.y)
  1588. .css({top: topOffset + pos.top, left: pos.left + leftOffset})
  1589. .show();
  1590. },
  1591. "mouseout": function (x) {
  1592. $(tt).hide();
  1593. }
  1594. };
  1595. var myChart = new xChart('line-dotted', data, '#chart3', opts);
  1596. }
  1597. function chart4() {
  1598. var data = {
  1599. "xScale": "ordinal",
  1600. "yScale": "linear",
  1601. "main": [
  1602. {
  1603. "className": ".pizza",
  1604. "data": [
  1605. {
  1606. "x": "Pepperoni",
  1607. "y": 4
  1608. },
  1609. {
  1610. "x": "Cheese",
  1611. "y": 8
  1612. }
  1613. ]
  1614. }
  1615. ]
  1616. };
  1617. var myChart = new xChart('bar', data, '#chart4');
  1618. }
  1619. function chart5() {
  1620. var data = {
  1621. "xScale": "ordinal",
  1622. "yScale": "linear",
  1623. "main": [
  1624. {
  1625. "className": ".pizza",
  1626. "data": [
  1627. {
  1628. "x": "Pepperoni",
  1629. "y": 4
  1630. },
  1631. {
  1632. "x": "Cheese",
  1633. "y": 8
  1634. }
  1635. ]
  1636. },
  1637. {
  1638. "className": ".pizza",
  1639. "data": [
  1640. {
  1641. "x": "Pepperoni",
  1642. "y": 6
  1643. },
  1644. {
  1645. "x": "Cheese",
  1646. "y": 5
  1647. }
  1648. ]
  1649. }
  1650. ]
  1651. };
  1652. var myChart = new xChart('bar', data, '#chart5');
  1653. }
  1654. function chart6() {
  1655. var errorBar = {
  1656. enter: function (self, storage, className, data, callbacks) {
  1657. var insertionPoint = xChart.visutils.getInsertionPoint(9),
  1658. container,
  1659. // Map each error bar into 3 points, so it's easier to draw as a single path
  1660. // Converts each point to a triplet with y from (y - e) to (y + e)
  1661. // It would be better to use the `preUpdateScale` method here,
  1662. // but for this quick example, we're taking a shortcut :)
  1663. eData = data.map(function (d) {
  1664. d.data = d.data.map(function (d) {
  1665. return [{x: d.x, y: d.y - d.e}, {x: d.x, y: d.y}, {x: d.x, y: d.y + d.e}];
  1666. });
  1667. return d;
  1668. }),
  1669. paths;
  1670. // It's always a good idea to create containers for sets
  1671. container = self._g.selectAll('.errorLine' + className)
  1672. .data(eData, function (d) {
  1673. return d.className;
  1674. });
  1675. // The insertionPoint is a special method that helps us insert this
  1676. // vis at a particular z-index
  1677. // In this case, we've chosen the highest point (above everything else)
  1678. container.enter().insert('g', insertionPoint)
  1679. .attr('class', function (d, i) {
  1680. return 'errorLine' + className.replace(/\./g, ' ') +
  1681. ' color' + i;
  1682. });
  1683. // Tell each path about its data
  1684. // and ensure we reuse any previously drawn item
  1685. paths = container.selectAll('path')
  1686. .data(function (d) {
  1687. return d.data;
  1688. }, function (d) {
  1689. return d[0].x;
  1690. });
  1691. paths.enter().insert('path')
  1692. .style('opacity', 0)
  1693. .attr('d', d3.svg.line()
  1694. .x(function (d) {
  1695. // We offset by half the rangeBand, because this is a bar chart
  1696. return self.xScale(d.x) + self.xScale.rangeBand() / 2;
  1697. })
  1698. .y(function (d) { return self.yScale(d.y); })
  1699. );
  1700. storage.containers = container;
  1701. storage.paths = paths;
  1702. },
  1703. update: function (self, storage, timing) {
  1704. // This is mostly duplication to the d3.svg.line from the enter() method
  1705. storage.paths.transition().duration(timing)
  1706. .style('opacity', 1)
  1707. .attr('d', d3.svg.line()
  1708. .x(function (d) {
  1709. return self.xScale(d.x) + self.xScale.rangeBand() / 2;
  1710. })
  1711. .y(function (d) { return self.yScale(d.y); })
  1712. );
  1713. },
  1714. exit: function (self, storage, timing) {
  1715. storage.paths.exit()
  1716. .transition().duration(timing)
  1717. .style('opacity', 0);
  1718. },
  1719. destroy: function (self, storage, timing) {
  1720. storage.paths.transition().duration(timing)
  1721. .style('opacity', 0)
  1722. .remove();
  1723. }
  1724. };
  1725. xChart.setVis('error', errorBar);
  1726. var data = [{
  1727. "xScale": "ordinal",
  1728. "yScale": "linear",
  1729. "main": [
  1730. {
  1731. "className": ".errorExample",
  1732. "data": [
  1733. {
  1734. "x": "Ponies",
  1735. "y": 12
  1736. },
  1737. {
  1738. "x": "Unicorns",
  1739. "y": 23
  1740. },
  1741. {
  1742. "x": "Trolls",
  1743. "y": 1
  1744. }
  1745. ]
  1746. }
  1747. ],
  1748. "comp": [
  1749. {
  1750. "type": "error",
  1751. "className": ".comp.errorBar",
  1752. "data": [
  1753. {
  1754. "x": "Ponies",
  1755. "y": 12,
  1756. "e": 5
  1757. },
  1758. {
  1759. "x": "Unicorns",
  1760. "y": 23,
  1761. "e": 2
  1762. },
  1763. {
  1764. "x": "Trolls",
  1765. "y": 1,
  1766. "e": 1
  1767. }
  1768. ]
  1769. }
  1770. ]
  1771. },
  1772. {
  1773. "xScale": "ordinal",
  1774. "yScale": "linear",
  1775. "main": [
  1776. {
  1777. "className": ".errorExample",
  1778. "data": [
  1779. {
  1780. "x": "Ponies",
  1781. "y": 76
  1782. },
  1783. {
  1784. "x": "Unicorns",
  1785. "y": 45
  1786. },
  1787. {
  1788. "x": "Trolls",
  1789. "y": 82
  1790. }
  1791. ]
  1792. }
  1793. ],
  1794. "comp": [
  1795. {
  1796. "type": "error",
  1797. "className": ".comp.errorBar",
  1798. "data": [
  1799. {
  1800. "x": "Ponies",
  1801. "y": 76,
  1802. "e": 12
  1803. },
  1804. {
  1805. "x": "Unicorns",
  1806. "y": 45,
  1807. "e": 3
  1808. },
  1809. {
  1810. "x": "Trolls",
  1811. "y": 82,
  1812. "e": 12
  1813. }
  1814. ]
  1815. }
  1816. ]
  1817. }
  1818. ];
  1819. var myChart = new xChart('bar', data[0], '#chart6'), i = 0;
  1820. function timer() {
  1821. setTimeout(function () {
  1822. timer();
  1823. i += 1;
  1824. myChart.setData(data[i % 2]);
  1825. }, 3000);
  1826. }
  1827. timer();
  1828. }
  1829. //Run all charts
  1830. chart1();
  1831. chart2();
  1832. chart3();
  1833. chart4();
  1834. chart5();
  1835. chart6();
  1836. }
  1837. /*-----------------------------------------------------------------------------------*/
  1838. /* Justgage
  1839. /*-----------------------------------------------------------------------------------*/
  1840. var handleGage = function () {
  1841. var g1, g2, g3, g4, g5, g6;
  1842. window.onload = function(){
  1843. var g1 = new JustGage({
  1844. id: "g1",
  1845. value: getRandomInt(0, 100),
  1846. min: 0,
  1847. max: 100,
  1848. title: "Custom Width",
  1849. label: "",
  1850. gaugeWidthScale: 0.2
  1851. });
  1852. var g2 = new JustGage({
  1853. id: "g2",
  1854. value: getRandomInt(0, 100),
  1855. min: 0,
  1856. max: 100,
  1857. title: "Custom Shadow",
  1858. label: "",
  1859. shadowOpacity: 1,
  1860. shadowSize: 0,
  1861. shadowVerticalOffset: 4
  1862. });
  1863. var g3 = new JustGage({
  1864. id: "g3",
  1865. value: getRandomInt(0, 100),
  1866. min: 0,
  1867. max: 100,
  1868. title: "Custom Colors",
  1869. label: "",
  1870. levelColors: [Theme.colors.red, Theme.colors.yellow, Theme.colors.green]
  1871. });
  1872. var g4 = new JustGage({
  1873. id: "g4",
  1874. value: getRandomInt(0, 100),
  1875. min: 0,
  1876. max: 100,
  1877. title: "Hide Labels",
  1878. showMinMax: false
  1879. });
  1880. var g5 = new JustGage({
  1881. id: "g5",
  1882. value: getRandomInt(0, 100),
  1883. min: 0,
  1884. max: 100,
  1885. title: "Animation Type",
  1886. label: "",
  1887. startAnimationTime: 2000,
  1888. startAnimationType: ">",
  1889. refreshAnimationTime: 1000,
  1890. refreshAnimationType: "bounce"
  1891. });
  1892. var g6 = new JustGage({
  1893. id: "g6",
  1894. value: getRandomInt(0, 100),
  1895. min: 0,
  1896. max: 100,
  1897. title: "Minimal",
  1898. label: "",
  1899. showMinMax: false,
  1900. gaugeColor: "#E6E6E6",
  1901. levelColors: ["#555555"],
  1902. showInnerShadow: false,
  1903. startAnimationTime: 1,
  1904. startAnimationType: "linear",
  1905. refreshAnimationTime: 1,
  1906. refreshAnimationType: "linear"
  1907. });
  1908. setInterval(function() {
  1909. g1.refresh(getRandomInt(0, 100));
  1910. g2.refresh(getRandomInt(0, 100));
  1911. g3.refresh(getRandomInt(0, 100));
  1912. g4.refresh(getRandomInt(0, 100));
  1913. g5.refresh(getRandomInt(0, 100));
  1914. g6.refresh(getRandomInt(0, 100));
  1915. }, 2500);
  1916. };
  1917. }
  1918. /*-----------------------------------------------------------------------------------*/
  1919. /* Easy Pie chart
  1920. /*-----------------------------------------------------------------------------------*/
  1921. var handleEasyPie = function () {
  1922. //Pie 1
  1923. $('#pie_1').easyPieChart({
  1924. easing: 'easeOutBounce',
  1925. onStep: function(from, to, percent) {
  1926. $(this.el).find('.percent').text(Math.round(percent));
  1927. },
  1928. lineWidth: 3,
  1929. barColor: '#A8BC7B'
  1930. });
  1931. var chart1 = window.chart = $('#pie_1').data('easyPieChart');
  1932. $('#js_update_1').on('click', function() {
  1933. chart1.update(Math.random()*100);
  1934. });
  1935. //Pie 2
  1936. $('#pie_2').easyPieChart({
  1937. easing: 'easeOutBounce',
  1938. onStep: function(from, to, percent) {
  1939. $(this.el).find('.percent').text(Math.round(percent));
  1940. },
  1941. lineWidth: 6,
  1942. barColor: '#F0AD4E'
  1943. });
  1944. var chart2 = window.chart = $('#pie_2').data('easyPieChart');
  1945. $('#js_update_2').on('click', function() {
  1946. chart2.update(Math.random()*100);
  1947. });
  1948. //Pie 3
  1949. $('#pie_3').easyPieChart({
  1950. easing: 'easeOutBounce',
  1951. onStep: function(from, to, percent) {
  1952. $(this.el).find('.percent').text(Math.round(percent));
  1953. },
  1954. lineWidth: 9,
  1955. barColor: '#D9534F'
  1956. });
  1957. var chart3 = window.chart = $('#pie_3').data('easyPieChart');
  1958. $('#js_update_3').on('click', function() {
  1959. chart3.update(Math.random()*100);
  1960. });
  1961. //Pie 4
  1962. $('#pie_4').easyPieChart({
  1963. easing: 'easeOutBounce',
  1964. onStep: function(from, to, percent) {
  1965. $(this.el).find('.percent').text(Math.round(percent));
  1966. },
  1967. lineWidth: 12,
  1968. barColor: '#70AFC4',
  1969. lineCap: 'butt'
  1970. });
  1971. var chart4 = window.chart = $('#pie_4').data('easyPieChart');
  1972. $('#js_update_4').on('click', function() {
  1973. chart4.update(Math.random()*100);
  1974. });
  1975. }
  1976. /*-----------------------------------------------------------------------------------*/
  1977. /* Easy Pie chart for profile
  1978. /*-----------------------------------------------------------------------------------*/
  1979. var handleProfileSkillPie = function () {
  1980. //Pie 1
  1981. $('#pie_1').easyPieChart({
  1982. easing: 'easeOutBounce',
  1983. onStep: function(from, to, percent) {
  1984. $(this.el).find('.percent').text(Math.round(percent)+"%");
  1985. },
  1986. lineWidth: 6,
  1987. barColor: '#F0AD4E'
  1988. });
  1989. var chart1 = window.chart = $('#pie_1').data('easyPieChart');
  1990. //Pie 2
  1991. $('#pie_2').easyPieChart({
  1992. easing: 'easeOutBounce',
  1993. onStep: function(from, to, percent) {
  1994. $(this.el).find('.percent').text(Math.round(percent)+"%");
  1995. },
  1996. lineWidth: 6,
  1997. barColor: '#D9534F'
  1998. });
  1999. var chart2 = window.chart = $('#pie_2').data('easyPieChart');
  2000. //Pie 3
  2001. $('#pie_3').easyPieChart({
  2002. easing: 'easeOutBounce',
  2003. onStep: function(from, to, percent) {
  2004. $(this.el).find('.percent').text(Math.round(percent)+"%");
  2005. },
  2006. lineWidth: 6,
  2007. barColor: '#70AFC4'
  2008. });
  2009. var chart3 = window.chart = $('#pie_3').data('easyPieChart');
  2010. }
  2011. /*-----------------------------------------------------------------------------------*/
  2012. /* Sparklines
  2013. /*-----------------------------------------------------------------------------------*/
  2014. var handleSparkline = function () {
  2015. //Sparkline bar
  2016. $(".sparkline").each(function() {
  2017. var barSpacing, barWidth, color, height;
  2018. color = $(this).attr("data-color") || "red";
  2019. height = "18px";
  2020. if ($(this).hasClass("big")) {
  2021. barWidth = "5px";
  2022. barSpacing = "2px";
  2023. height = "40px";
  2024. }
  2025. return $(this).sparkline("html", {
  2026. type: "bar",
  2027. barColor: Theme.colors[color],
  2028. height: height,
  2029. barWidth: barWidth,
  2030. barSpacing: barSpacing,
  2031. zeroAxis: false
  2032. });
  2033. });
  2034. //Sparkline Pie
  2035. $(".sparklinepie").each(function() {
  2036. var height;
  2037. height = "50px";
  2038. if ($(this).hasClass("big")) {
  2039. height = "70px";
  2040. }
  2041. return $(this).sparkline("html", {
  2042. type: "pie",
  2043. height: height,
  2044. sliceColors: [Theme.colors.blue, Theme.colors.red, Theme.colors.green, Theme.colors.orange]
  2045. });
  2046. });
  2047. //Sparkline Line
  2048. $(".linechart").each(function() {
  2049. var height;
  2050. height = "18px";
  2051. if ($(this).hasClass("linechart-lg")) {
  2052. height = "30px";
  2053. }
  2054. return $(this).sparkline("html", {
  2055. type: "line",
  2056. height: height,
  2057. width: "150px",
  2058. minSpotColor: Theme.colors.red,
  2059. maxSpotColor: Theme.colors.green,
  2060. spotRadius: 3,
  2061. lineColor: Theme.colors.primary,
  2062. fillColor: "rgba(94,135,176,0.1)",
  2063. lineWidth: 1.2,
  2064. highlightLineColor: Theme.colors.red,
  2065. highlightSpotColor: Theme.colors.yellow
  2066. });
  2067. });
  2068. }
  2069. /*-----------------------------------------------------------------------------------*/
  2070. /* Fullcalendar
  2071. /*-----------------------------------------------------------------------------------*/
  2072. var handleCalendar = function () {
  2073. /* initialize the external events
  2074. -----------------------------------------------------------------*/
  2075. var initDrag = function (el) {
  2076. // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
  2077. // it doesn't need to have a start or end
  2078. var eventObject = {
  2079. title: $.trim(el.text()) // use the element's text as the event title
  2080. };
  2081. // store the Event Object in the DOM element so we can get to it later
  2082. el.data('eventObject', eventObject);
  2083. // make the event draggable using jQuery UI
  2084. el.draggable({
  2085. zIndex: 999,
  2086. revert: true, // will cause the event to go back to its
  2087. revertDuration: 0 // original position after the drag
  2088. });
  2089. }
  2090. var addEvent = function (title) {
  2091. title = title.length == 0 ? "Untitled Event" : title;
  2092. var html = $('<div class="external-event">' + title + '</div>');
  2093. jQuery('#event-box').append(html);
  2094. initDrag(html);
  2095. }
  2096. $('#external-events div.external-event').each(function () {
  2097. initDrag($(this))
  2098. });
  2099. $('#add-event').unbind('click').click(function () {
  2100. var title = $('#event-title').val();
  2101. addEvent(title);
  2102. });
  2103. /* initialize the calendar
  2104. -----------------------------------------------------------------*/
  2105. var date = new Date();
  2106. var d = date.getDate();
  2107. var m = date.getMonth();
  2108. var y = date.getFullYear();
  2109. var calendar = $('#calendar').fullCalendar({
  2110. header: {
  2111. left: 'prev,next today',
  2112. center: 'title',
  2113. right: 'month,agendaWeek,agendaDay'
  2114. },
  2115. selectable: true,
  2116. selectHelper: true,
  2117. select: function(start, end, allDay) {
  2118. var title = prompt('Event Title:');
  2119. if (title) {
  2120. calendar.fullCalendar('renderEvent',
  2121. {
  2122. title: title,
  2123. start: start,
  2124. end: end,
  2125. allDay: allDay
  2126. },
  2127. true // make the event "stick"
  2128. );
  2129. }
  2130. calendar.fullCalendar('unselect');
  2131. },
  2132. editable: true,
  2133. editable: true,
  2134. droppable: true, // this allows things to be dropped onto the calendar !!!
  2135. drop: function(date, allDay) { // this function is called when something is dropped
  2136. // retrieve the dropped element's stored Event Object
  2137. var originalEventObject = $(this).data('eventObject');
  2138. // we need to copy it, so that multiple events don't have a reference to the same object
  2139. var copiedEventObject = $.extend({}, originalEventObject);
  2140. // assign it the date that was reported
  2141. copiedEventObject.start = date;
  2142. copiedEventObject.allDay = allDay;
  2143. // render the event on the calendar
  2144. // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
  2145. $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
  2146. // is the "remove after drop" checkbox checked?
  2147. if ($('#drop-remove').is(':checked')) {
  2148. // if so, remove the element from the "Draggable Events" list
  2149. $(this).remove();
  2150. }
  2151. },
  2152. events: [
  2153. {
  2154. title: 'All Day Event',
  2155. start: new Date(y, m, 1),
  2156. backgroundColor: Theme.colors.blue,
  2157. },
  2158. {
  2159. title: 'Long Event',
  2160. start: new Date(y, m, d-5),
  2161. end: new Date(y, m, d-2),
  2162. backgroundColor: Theme.colors.red,
  2163. },
  2164. {
  2165. id: 999,
  2166. title: 'Repeating Event',
  2167. start: new Date(y, m, d-3, 16, 0),
  2168. allDay: false,
  2169. backgroundColor: Theme.colors.yellow,
  2170. },
  2171. {
  2172. id: 999,
  2173. title: 'Repeating Event',
  2174. start: new Date(y, m, d+4, 16, 0),
  2175. allDay: false,
  2176. backgroundColor: Theme.colors.primary,
  2177. },
  2178. {
  2179. title: 'Meeting',
  2180. start: new Date(y, m, d, 10, 30),
  2181. allDay: false,
  2182. backgroundColor: Theme.colors.green,
  2183. },
  2184. {
  2185. title: 'Lunch',
  2186. start: new Date(y, m, d, 12, 0),
  2187. end: new Date(y, m, d, 14, 0),
  2188. allDay: false,
  2189. backgroundColor: Theme.colors.red,
  2190. },
  2191. {
  2192. title: 'Birthday Party',
  2193. start: new Date(y, m, d+1, 19, 0),
  2194. end: new Date(y, m, d+1, 22, 30),
  2195. allDay: false,
  2196. backgroundColor: Theme.colors.gray,
  2197. },
  2198. {
  2199. title: 'Click for Google',
  2200. start: new Date(y, m, 28),
  2201. end: new Date(y, m, 29),
  2202. url: 'http://google.com/',
  2203. backgroundColor: Theme.colors.green,
  2204. }
  2205. ]
  2206. });
  2207. }
  2208. /*-----------------------------------------------------------------------------------*/
  2209. /* JQVmaps
  2210. /*-----------------------------------------------------------------------------------*/
  2211. var handleJqvmaps = function () {
  2212. var setMap = function (name) {
  2213. var data = {
  2214. map: 'world_en',
  2215. backgroundColor: null,
  2216. borderColor: '#333333',
  2217. borderOpacity: 0.5,
  2218. borderWidth: 1,
  2219. color: Theme.colors.blue,
  2220. enableZoom: true,
  2221. hoverColor: Theme.colors.yellow,
  2222. hoverOpacity: null,
  2223. values: sample_data,
  2224. normalizeFunction: 'linear',
  2225. scaleColors: ['#b6da93', '#427d1a'],
  2226. selectedColor: '#c9dfaf',
  2227. selectedRegion: null,
  2228. showTooltip: true,
  2229. onRegionOver: function (event, code) {
  2230. //sample to interact with map
  2231. if (code == 'ca') {
  2232. event.preventDefault();
  2233. }
  2234. },
  2235. onRegionClick: function (element, code, region) {
  2236. //sample to interact with map
  2237. var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase();
  2238. alert(message);
  2239. }
  2240. };
  2241. data.map = name + '_en';
  2242. var map = jQuery('#vmap_' + name);
  2243. if (!map) {
  2244. return;
  2245. }
  2246. map.width(map.parent().width());
  2247. map.vectorMap(data);
  2248. }
  2249. //Init the maps
  2250. setMap("world");
  2251. setMap("usa");
  2252. setMap("europe");
  2253. setMap("russia");
  2254. setMap("germany");
  2255. App.addResponsiveFunction(function(){
  2256. setMap("world");
  2257. setMap("usa");
  2258. setMap("europe");
  2259. setMap("russia");
  2260. setMap("germany");
  2261. });
  2262. }
  2263. /*-----------------------------------------------------------------------------------*/
  2264. /* Isotope
  2265. /*-----------------------------------------------------------------------------------*/
  2266. var handleIsotope = function () {
  2267. // cache container
  2268. var $container = $('#filter-items');
  2269. // initialize isotope after image loaded
  2270. $container.imagesLoaded( function(){
  2271. $container.isotope({
  2272. // options...
  2273. });
  2274. // filter items when filter link is clicked
  2275. $('#filter-controls a').click(function(){
  2276. var selector = $(this).attr('data-filter');
  2277. $container.isotope({ filter: selector });
  2278. return false;
  2279. });
  2280. // filter on smaller screens
  2281. $("#e1").change(function(){
  2282. var selector = $(this).find(":selected").val();
  2283. $container.isotope({ filter: selector });
  2284. return false;
  2285. });
  2286. });
  2287. function handleIsotopeStretch() {
  2288. var width = $(window).width();
  2289. if ( width < 768 ) {
  2290. $('#filter-items .item').addClass('width-100');
  2291. }
  2292. else {
  2293. $('#filter-items .item').removeClass('width-100');
  2294. }
  2295. }
  2296. handleIsotopeStretch();
  2297. /* On Resize show menu on desktop if hidden */
  2298. jQuery(window).resize(function() {
  2299. handleIsotopeStretch();
  2300. });
  2301. }
  2302. /*-----------------------------------------------------------------------------------*/
  2303. /* Handle hover in gallery
  2304. /*-----------------------------------------------------------------------------------*/
  2305. var handleHover = function () {
  2306. $('.filter-content').hover(function() {
  2307. var hoverContent = $(this).children('.hover-content');
  2308. hoverContent.removeClass('fadeOut').addClass('animated fadeIn').show();
  2309. }, function() {
  2310. var hoverContent = $(this).children('.hover-content');
  2311. hoverContent.removeClass('fadeIn').addClass('fadeOut');
  2312. });
  2313. }
  2314. /*-----------------------------------------------------------------------------------*/
  2315. /* Handle Colorbox
  2316. /*-----------------------------------------------------------------------------------*/
  2317. var handleColorbox = function () {
  2318. $('.colorbox-button').colorbox({rel:'colorbox-button',maxWidth:'95%', maxHeight:'95%'});
  2319. /* Colorbox resize function */
  2320. var resizeTimer;
  2321. function resizeColorBox()
  2322. {
  2323. if (resizeTimer) clearTimeout(resizeTimer);
  2324. resizeTimer = setTimeout(function() {
  2325. var myWidth = 442, percentageWidth = .95;
  2326. if (jQuery('#cboxOverlay').is(':visible')) {
  2327. $.colorbox.resize({ width: ( $(window).width() > ( myWidth+20) )? myWidth : Math.round( $(window).width()*percentageWidth ) });
  2328. $('.cboxPhoto').css( {
  2329. width: $('#cboxLoadedContent').innerWidth(),
  2330. height: 'auto'
  2331. });
  2332. $('#cboxLoadedContent').height( $('.cboxPhoto').height() );
  2333. $.colorbox.resize();
  2334. }
  2335. }, 300)
  2336. }
  2337. // Resize Colorbox when resizing window or changing mobile device orientation
  2338. jQuery(window).resize(resizeColorBox);
  2339. window.addEventListener("orientationchange", resizeColorBox, false);
  2340. }
  2341. /*-----------------------------------------------------------------------------------*/
  2342. /* Handle Backstretch
  2343. /*-----------------------------------------------------------------------------------*/
  2344. var handleBackstretch = function () {
  2345. $.backstretch([
  2346. "img/login/1.jpg"
  2347. , "img/login/2.jpg"
  2348. , "img/login/3.jpg"
  2349. , "img/login/4.jpg"
  2350. ], {duration: 3000, fade: 750});
  2351. }
  2352. /*-----------------------------------------------------------------------------------*/
  2353. /* Handle Chat
  2354. /*-----------------------------------------------------------------------------------*/
  2355. var handleChat = function (elem) {
  2356. var append = function() {
  2357. //Check if chat is empty
  2358. var input = $('.'+elem+' .chat-form input');
  2359. var text = input.val();
  2360. if (text.length == 0) {
  2361. return;
  2362. }
  2363. //Get time
  2364. var curr_time = moment().format('YYYY-MM-DD HH:mm:ss');
  2365. var msg = '';
  2366. msg +='<li class="animated fadeInLeft media">';
  2367. msg += '<a class="pull-right" href="#">';
  2368. msg += '<img class="media-object" alt="Generic placeholder image" src="img/chat/headshot2.jpg">';
  2369. msg += '</a>';
  2370. msg += '<div class="pull-right media-body chat-pop mod">';
  2371. msg += '<h4 class="media-heading">You <span class="pull-left"><abbr id="curr-time" class="timeago" title="'+curr_time+'" >'+curr_time+'</abbr> <i class="fa fa-clock-o"></i></span></h4>';
  2372. msg += text;
  2373. msg += '</div>';
  2374. msg +='</li>';
  2375. var list = $('.'+elem+' .chat-list');
  2376. list.append(msg);
  2377. jQuery("abbr.timeago").timeago();
  2378. input.val("");
  2379. $('.'+elem+' .scroller').slimScroll({
  2380. scrollTo: list.height()
  2381. });
  2382. }
  2383. //If button is pressed
  2384. $('.'+elem+' .chat-form .btn').click(function(e){
  2385. e.preventDefault();
  2386. append();
  2387. });
  2388. var input = $('.'+elem+' .chat-form input');
  2389. //If Enter is pressed
  2390. input.keypress(function (e) {
  2391. if (e.which == 13) {
  2392. append();
  2393. return false;
  2394. }
  2395. });
  2396. }
  2397. /*-----------------------------------------------------------------------------------*/
  2398. /* Handle Timeline
  2399. /*-----------------------------------------------------------------------------------*/
  2400. var handleTimeline = function () {
  2401. createStoryJS({
  2402. type: 'timeline',
  2403. width: '100%',
  2404. height: '600',
  2405. source: 'js/timelinejs/example_json.json',
  2406. embed_id: 'my-timeline',
  2407. debug: true,
  2408. css: 'js/timelinejs/css/timeline.css',
  2409. js: 'js/timelinejs/js/timeline-min.js'
  2410. });
  2411. }
  2412. /*-----------------------------------------------------------------------------------*/
  2413. /* Handle Slidernav
  2414. /*-----------------------------------------------------------------------------------*/
  2415. var handleSliderNav = function () {
  2416. $('#address-book').sliderNav();
  2417. $('#address-book .slider-content ul li ul li a').click(function(e){
  2418. e.preventDefault();
  2419. var contact_card = $('#contact-card');
  2420. //Get the name clicked on
  2421. var name = $(this).text();
  2422. //Set the name
  2423. $('#contact-card .panel-title').html(name);
  2424. $('#contact-card #card-name').html(name);
  2425. //Randomize the image
  2426. var img_id = Math.floor(Math.random() * (5 - 1 + 1)) + 1;
  2427. //Set the image
  2428. $('#contact-card .headshot img').attr('src', 'img/addressbook/'+img_id+'.jpg');
  2429. contact_card.removeClass('animated fadeInUp').addClass('animated fadeInUp');
  2430. var wait = window.setTimeout( function(){
  2431. contact_card.removeClass('animated fadeInUp')},
  2432. 1300
  2433. );
  2434. });
  2435. }
  2436. /*-----------------------------------------------------------------------------------*/
  2437. /* Handle Active Toggle
  2438. /*-----------------------------------------------------------------------------------*/
  2439. var handleActiveToggle = function () {
  2440. $('#list-toggle .list-group a').click(function(){
  2441. $('#list-toggle .list-group > a.active').removeClass('active');
  2442. $(this).addClass('active');
  2443. })
  2444. }
  2445. /*-----------------------------------------------------------------------------------*/
  2446. /* Handle Box Sortable
  2447. /*-----------------------------------------------------------------------------------*/
  2448. var handleBoxSortable = function () {
  2449. $('.box-container').sortable({
  2450. connectWith: '.box-container',
  2451. items:'> .box',
  2452. opacity:0.8,
  2453. revert:true,
  2454. forceHelperSize:true,
  2455. placeholder: 'box-placeholder',
  2456. forcePlaceholderSize:true,
  2457. tolerance:'pointer'
  2458. });
  2459. }
  2460. /*-----------------------------------------------------------------------------------*/
  2461. /* Handles the go to top button at the footer
  2462. /*-----------------------------------------------------------------------------------*/
  2463. var handleGoToTop = function () {
  2464. $('.footer-tools').on('click', '.go-top', function (e) {
  2465. App.scrollTo();
  2466. e.preventDefault();
  2467. });
  2468. }
  2469. /*-----------------------------------------------------------------------------------*/
  2470. /* Handles navbar fixed top
  2471. /*-----------------------------------------------------------------------------------*/
  2472. var handleNavbarFixedTop = function () {
  2473. if(is_mobile && is_fixed_header) {
  2474. //Manage margin top
  2475. $('#main-content').addClass('margin-top-100');
  2476. }
  2477. if(!(is_mobile) && is_fixed_header){
  2478. //Manage margin top
  2479. $('#main-content').removeClass('margin-top-100').addClass('margin-top-50');
  2480. }
  2481. }
  2482. /*-----------------------------------------------------------------------------------*/
  2483. /* Handles flot charts in dashboard
  2484. /*-----------------------------------------------------------------------------------*/
  2485. var handleDashFlotCharts = function () {
  2486. //Revenue chart
  2487. function chart_revenue(str,data,labelstr) {
  2488. var likes = data;
  2489. var chartColor = $(this).parent().parent().css("color");
  2490. var plot = $.plot($(str),
  2491. [ { data: likes} ], {
  2492. series: {
  2493. label: labelstr,
  2494. lines: {
  2495. show: true,
  2496. lineWidth: 3,
  2497. fill: false
  2498. },
  2499. points: {
  2500. show: true,
  2501. lineWidth: 3,
  2502. fill: true,
  2503. fillColor: chartColor
  2504. },
  2505. shadowSize: 0
  2506. },
  2507. grid: { hoverable: true,
  2508. clickable: true,
  2509. tickColor: "rgba(255,255,255,.15)",
  2510. borderColor: "rgba(255,255,255,0)"
  2511. },
  2512. colors: ["#fff"],
  2513. xaxis: {
  2514. font: {
  2515. color: "#fff"
  2516. },
  2517. //ticks:6,
  2518. //tickDecimals: 0,
  2519. tickColor: chartColor,
  2520. ticks: [[1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10"]
  2521. , [11, "11"], [12, "12"], [13, "13"], [14, "14"], [15, "15"], [16, "16"], [17, "17"], [18, "18"], [19, "19"], [20, "20"]
  2522. , [21, "21"], [22, "22"], [23, "23"], [24, "24"], [25, "25"], [26, "26"], [27, "27"], [28, "28"], [29, "29"], [30, "30"]
  2523. , [31, "31"]], min: 1, max: 31
  2524. },
  2525. yaxis: {
  2526. font: {
  2527. color: "#fff"
  2528. },
  2529. ticks:4,
  2530. tickDecimals: 0,
  2531. autoscaleMargin: 0.000001
  2532. },
  2533. legend: {
  2534. show: false
  2535. }
  2536. });
  2537. function showTooltip(x, y, contents) {
  2538. $('<div id="tooltip">' + contents + '</div>').css( {
  2539. position: 'absolute',
  2540. display: 'none',
  2541. top: y + 5,
  2542. left: x + 5,
  2543. border: '1px solid #fdd',
  2544. padding: '2px',
  2545. 'background-color': '#dfeffc',
  2546. opacity: 0.80
  2547. }).appendTo("body").fadeIn(200);
  2548. }
  2549. var previousPoint = null;
  2550. $(str).bind("plothover", function (event, pos, item) {
  2551. $("#x").text(pos.x.toFixed(2));
  2552. $("#y").text(pos.y.toFixed(2));
  2553. if (item) {
  2554. if (previousPoint != item.dataIndex) {
  2555. previousPoint = item.dataIndex;
  2556. $("#tooltip").remove();
  2557. var x = item.datapoint[0],
  2558. y = item.datapoint[1].toFixed(2);
  2559. showTooltip(item.pageX, item.pageY,
  2560. item.series.label + " " + x + " = " + y);
  2561. }
  2562. }
  2563. else {
  2564. $("#tooltip").remove();
  2565. previousPoint = null;
  2566. }
  2567. });
  2568. }
  2569. //Run the charts
  2570. //chartMonth();
  2571. //chart_select();
  2572. chart_revenue("#chart-revenue",paydata,"金额");
  2573. chart_revenue("#chart-revenue2",logindata,"数量");
  2574. chart_revenue("#chart-pay",regdata,"数量");
  2575. chart_revenue("#chart-login",upaydata,"数量");
  2576. }
  2577. /*-----------------------------------------------------------------------------------*/
  2578. /* Handles vertically growing bars
  2579. /*-----------------------------------------------------------------------------------*/
  2580. var handleVerticalChart = function () {
  2581. if($('.verticalChart')) {
  2582. $('.singleBar').each(function(){
  2583. var percent = $(this).find('.value span').html();
  2584. $(this).find('.value').animate({height:percent}, 2000, function() {
  2585. $(this).find('span').fadeIn();
  2586. });
  2587. });
  2588. }
  2589. }
  2590. /*-----------------------------------------------------------------------------------*/
  2591. /* Handles theme skin switches
  2592. /*-----------------------------------------------------------------------------------*/
  2593. var handleThemeSkins = function () {
  2594. // Handle theme colors
  2595. var setSkin = function (color) {
  2596. $('#skin-switcher').attr("href", "css/themes/" + color + ".css");
  2597. $.cookie('skin_color', color);
  2598. }
  2599. $('ul.skins > li a').click(function () {
  2600. var color = $(this).data("skin");
  2601. setSkin(color);
  2602. });
  2603. //Check which theme skin is set
  2604. if ($.cookie('skin_color')) {
  2605. setSkin($.cookie('skin_color'));
  2606. }
  2607. }
  2608. /*-----------------------------------------------------------------------------------*/
  2609. /* Handles Gritter on Load
  2610. /*-----------------------------------------------------------------------------------*/
  2611. var handleGritter = function () {
  2612. if ($.cookie('gritter_show')) {
  2613. return;
  2614. }
  2615. $.cookie('gritter_show', 1);
  2616. setTimeout(function () {
  2617. var unique_id = $.gritter.add({
  2618. // (string | mandatory) the heading of the notification
  2619. title: 'Welcome to Cloud Admin!',
  2620. // (string | mandatory) the text inside the notification
  2621. text: 'Cloud is a feature-rich Responsive Admin Dashboard Template with a wide array of plugins!',
  2622. // (string | optional) the image to display on the left
  2623. image: 'img/gritter/cloud.png',
  2624. // (bool | optional) if you want it to fade out on its own or just sit there
  2625. sticky: true,
  2626. // (int | optional) the time you want it to be alive for before fading out
  2627. time: '',
  2628. // (string | optional) the class name you want to apply to that specific message
  2629. class_name: 'my-sticky-class'
  2630. });
  2631. // You can have it return a unique id, this can be used to manually remove it later using
  2632. setTimeout(function () {
  2633. $.gritter.remove(unique_id, {
  2634. fade: true,
  2635. speed: 'slow'
  2636. });
  2637. }, 12000);
  2638. }, 2000);
  2639. setTimeout(function () {
  2640. var unique_id = $.gritter.add({
  2641. // (string | mandatory) the heading of the notification
  2642. title: 'Customize Cloud Admin!',
  2643. // (string | mandatory) the text inside the notification
  2644. text: 'Cloud Admin is easily customizable, lightweight and has a great User Experience.',
  2645. // (string | optional) the image to display on the left
  2646. image: 'img/gritter/settings.png',
  2647. // (bool | optional) if you want it to fade out on its own or just sit there
  2648. sticky: true,
  2649. // (int | optional) the time you want it to be alive for before fading out
  2650. time: '',
  2651. // (string | optional) the class name you want to apply to that specific message
  2652. class_name: 'my-sticky-class'
  2653. });
  2654. // You can have it return a unique id, this can be used to manually remove it later using
  2655. setTimeout(function () {
  2656. $.gritter.remove(unique_id, {
  2657. fade: true,
  2658. speed: 'slow'
  2659. });
  2660. }, 13000);
  2661. }, 8000);
  2662. setTimeout(function () {
  2663. $.extend($.gritter.options, {
  2664. position: 'top-left'
  2665. });
  2666. var unique_id = $.gritter.add({
  2667. position: 'top-left',
  2668. // (string | mandatory) the heading of the notification
  2669. title: 'Buy Cloud Admin!',
  2670. // (string | mandatory) the text inside the notification
  2671. text: 'Purchase Cloud Admin theme and get access to future updates at no extra cost. Buy now!',
  2672. // (string | optional) the image to display on the left
  2673. image: 'img/gritter/buy.png',
  2674. // (bool | optional) if you want it to fade out on its own or just sit there
  2675. sticky: true,
  2676. // (int | optional) the time you want it to be alive for before fading out
  2677. time: '',
  2678. // (string | optional) the class name you want to apply to that specific message
  2679. class_name: 'my-sticky-class'
  2680. });
  2681. $.extend($.gritter.options, {
  2682. position: 'top-right'
  2683. });
  2684. // You can have it return a unique id, this can be used to manually remove it later using
  2685. setTimeout(function () {
  2686. $.gritter.remove(unique_id, {
  2687. fade: true,
  2688. speed: 'slow'
  2689. });
  2690. }, 15000);
  2691. }, 15000);
  2692. setTimeout(function () {
  2693. $.extend($.gritter.options, {
  2694. position: 'top-left'
  2695. });
  2696. var unique_id = $.gritter.add({
  2697. // (string | mandatory) the heading of the notification
  2698. title: 'Notification',
  2699. // (string | mandatory) the text inside the notification
  2700. text: 'You have 6 new notifications.',
  2701. // (bool | optional) if you want it to fade out on its own or just sit there
  2702. sticky: true,
  2703. // (int | optional) the time you want it to be alive for before fading out
  2704. time: '',
  2705. // (string | optional) the class name you want to apply to that specific message
  2706. class_name: 'my-sticky-class'
  2707. });
  2708. setTimeout(function () {
  2709. $.gritter.remove(unique_id, {
  2710. fade: true,
  2711. speed: 'slow'
  2712. });
  2713. }, 4000);
  2714. $.extend($.gritter.options, {
  2715. position: 'top-right'
  2716. });
  2717. }, 20000);
  2718. setTimeout(function () {
  2719. $.extend($.gritter.options, {
  2720. position: 'top-left'
  2721. });
  2722. var unique_id = $.gritter.add({
  2723. // (string | mandatory) the heading of the notification
  2724. title: 'Inbox',
  2725. // (string | mandatory) the text inside the notification
  2726. text: 'You have 5 new messages in your inbox.',
  2727. // (bool | optional) if you want it to fade out on its own or just sit there
  2728. sticky: true,
  2729. // (int | optional) the time you want it to be alive for before fading out
  2730. time: '',
  2731. // (string | optional) the class name you want to apply to that specific message
  2732. class_name: 'my-sticky-class'
  2733. });
  2734. $.extend($.gritter.options, {
  2735. position: 'top-right'
  2736. });
  2737. setTimeout(function () {
  2738. $.gritter.remove(unique_id, {
  2739. fade: true,
  2740. speed: 'slow'
  2741. });
  2742. }, 4000);
  2743. }, 25000);
  2744. }
  2745. /*-----------------------------------------------------------------------------------*/
  2746. /* Handles Profile Edit
  2747. /*-----------------------------------------------------------------------------------*/
  2748. var handleProfileEdit = function () {
  2749. $(".datepicker").datepicker();
  2750. }
  2751. return {
  2752. //Initialise theme pages
  2753. init: function () {
  2754. if (App.isPage("index")) {
  2755. //handleDateTimePickers(); //Function to display Date Timepicker
  2756. //handleSparkline(); //Function to display Sparkline charts
  2757. handleDashFlotCharts(); //Function to display flot charts in dashboard
  2758. handleChat('chat-window'); //Function to handle chat
  2759. //handleCalendar(); //Function to display calendar
  2760. //handleGritter(); //Function to display Gritter notifications
  2761. }
  2762. if (App.isPage("widgets_box")) {
  2763. handleBoxSortable(); //Function to handle Box sortables
  2764. }
  2765. if (App.isPage("elements")) {
  2766. handleBootbox(); //Function to display Date Timepicker
  2767. handleMagicSuggest(); //Function to display autosuggest
  2768. handleDateColorpicker(); //Function to handle date and time picker
  2769. handleRaty(); //To show star ratings
  2770. handleTimeAgo(); //Function to handle timestamps
  2771. }
  2772. if (App.isPage("button_icons")) {
  2773. handleStatefulButtons(); //Function to display stateful buttons
  2774. handleToggle(); //Function to handle toggle buttons
  2775. }
  2776. if (App.isPage("sliders_progress")) {
  2777. handleSliders(); //Function to display sliders
  2778. handleProgress(); //Function to display progress bars
  2779. handleKnobs(); //Function to display knobs
  2780. }
  2781. if (App.isPage("treeview")) {
  2782. handleTree(); //Function to handle tree display
  2783. }
  2784. if (App.isPage("nestable_lists")) {
  2785. handleNestableLists(); //Function to handle nestable lists
  2786. }
  2787. if (App.isPage("simple_table")) {
  2788. handleTablecloth(); //Function to display tablecloth.js options
  2789. }
  2790. if (App.isPage("dynamic_table")) {
  2791. handleDataTables(); //Function to display data tables
  2792. }
  2793. if (App.isPage("jqgrid_plugin")) {
  2794. handleJqgrid(); //Function to display jqGrid
  2795. }
  2796. if (App.isPage("forms")) {
  2797. handleTypeahead(); //Function to display autocomplete
  2798. handleAutosize(); //Function to handle textarea autosize
  2799. handleCountable(); //Function to handle char count
  2800. handleSelect2(); //Function to handle select2
  2801. handleUniform(); //Function to handle uniform inputs
  2802. handleTimeAgo(); //Function to handle timestamps
  2803. }
  2804. if (App.isPage("rich_text_editors")) {
  2805. handleWysiwyg(); //Function to display wysiwyg
  2806. }
  2807. if (App.isPage("dropzone_file_upload")) {
  2808. handleDropzone(); //Function to display wysiwyg
  2809. }
  2810. if (App.isPage("xcharts")) {
  2811. handleXcharts(); //Function to display xcharts
  2812. }
  2813. if (App.isPage("others")) {
  2814. handleGage(); //Function to display justgage
  2815. handleEasyPie(); //Function to display easy pie charts
  2816. handleSparkline(); //Function to display sparklines
  2817. }
  2818. if (App.isPage("calendar")) {
  2819. handleCalendar(); //Function to display calendar
  2820. handleUniform(); //Function to handle uniform inputs
  2821. }
  2822. if (App.isPage("vector_maps")) {
  2823. handleJqvmaps(); //Function to display vector maps
  2824. }
  2825. if (App.isPage("gallery")) {
  2826. handleIsotope(); //Function to display portfolio
  2827. handleHover(); //Function to display hover-content
  2828. handleColorbox(); //Function to display colorbox
  2829. }
  2830. if (App.isPage("login")) {
  2831. handleUniform(); //Function to handle uniform inputs
  2832. }
  2833. if (App.isPage("wizards_validations")) {
  2834. handleUniform(); //Function to handle uniform inputs
  2835. }
  2836. if (App.isPage("login_bg")) {
  2837. handleUniform(); //Function to handle uniform inputs
  2838. handleBackstretch(); //Function to handle background images
  2839. }
  2840. if (App.isPage("chats")) {
  2841. handleChat('chat-window'); //Function to handle chat
  2842. handleChat('chat-widget'); //Function to handle chat
  2843. initTimeAgo(); //Function to init timestamps
  2844. }
  2845. if (App.isPage("todo_timeline")) {
  2846. handleTimeline(); //Function to display timeline
  2847. }
  2848. if (App.isPage("address_book")) {
  2849. handleSliderNav(); //Function to display address book
  2850. }
  2851. if (App.isPage("orders")) {
  2852. initTimeAgo(); //Function to init timestamps
  2853. }
  2854. if (App.isPage("faq")) {
  2855. handleActiveToggle(); //Function to handle active toggle
  2856. }
  2857. if (App.isPage("user_profile")) {
  2858. handleProfileSkillPie(); //Function to show skills in pie
  2859. handleSparkline(); //Function to display sparklines
  2860. handleUniform(); //Function to handle uniform inputs
  2861. handleProfileEdit(); //Function to handle profile edit tab
  2862. }
  2863. if (App.isPage("mini_sidebar")) {
  2864. collapseSidebar(); //Function to display mini menu
  2865. }
  2866. if (App.isPage("fixed_header_sidebar")) {
  2867. handleFixedSidebar(); //Function to display fixed sidebar
  2868. }
  2869. //checkLayout(); //Function to check if mini menu/fixed header is activated
  2870. handleSidebar(); //Function to display the sidebar
  2871. handleSidebarCollapse(); //Function to hide or show sidebar
  2872. handleSidebarAndContentHeight(); //Function to hide sidebar and main content height
  2873. responsiveSidebar(); //Function to handle sidebar responsively
  2874. //handleTeamView(); //Function to toggle team view
  2875. //handleHomePageTooltips(); //Function to handle tooltips
  2876. handleBoxTools(); //Function to handle box tools
  2877. handleSlimScrolls(); //Function to handle slim scrolls
  2878. //handlePopovers(); //Function to handle popovers
  2879. //handleMessenger(); //Function to handle messenger
  2880. handleAlerts(); //Function to handle alerts
  2881. //handleCustomTabs(); //Function to handle min-height of custom tabs
  2882. handleGoToTop(); //Funtion to handle goto top buttons
  2883. //handleNavbarFixedTop(); //Function to check & handle if navbar is fixed top
  2884. handleThemeSkins(); //Function to handle theme skins
  2885. },
  2886. //Set page
  2887. setPage: function (name) {
  2888. currentPage = name;
  2889. },
  2890. //Set index data
  2891. setIndexData: function (data1,data2,data3,data4) {
  2892. paydata = data1;
  2893. logindata = data2;
  2894. regdata = data3;
  2895. upaydata = data4;
  2896. },
  2897. isPage: function (name) {
  2898. return currentPage == name ? true : false;
  2899. },
  2900. //public function to add callback a function which will be called on window resize
  2901. addResponsiveFunction: function (func) {
  2902. responsiveFunctions.push(func);
  2903. },
  2904. // wrapper function to scroll(focus) to an element
  2905. scrollTo: function (el, offeset) {
  2906. pos = (el && el.size() > 0) ? el.offset().top : 0;
  2907. jQuery('html,body').animate({
  2908. scrollTop: pos + (offeset ? offeset : 0)
  2909. }, 'slow');
  2910. },
  2911. // function to scroll to the top
  2912. scrollTop: function () {
  2913. App.scrollTo();
  2914. },
  2915. // initializes uniform elements
  2916. initUniform: function (els) {
  2917. if (els) {
  2918. jQuery(els).each(function () {
  2919. if ($(this).parents(".checker").size() == 0) {
  2920. $(this).show();
  2921. $(this).uniform();
  2922. }
  2923. });
  2924. } else {
  2925. handleAllUniform();
  2926. }
  2927. },
  2928. // wrapper function to block element(indicate loading)
  2929. blockUI: function (el, loaderOnTop) {
  2930. lastBlockedUI = el;
  2931. jQuery(el).block({
  2932. message: '<img src="./statics/CloudAdmin/img/loaders/12.gif" align="absmiddle">',
  2933. css: {
  2934. border: 'none',
  2935. padding: '2px',
  2936. backgroundColor: 'none'
  2937. },
  2938. overlayCSS: {
  2939. backgroundColor: '#000',
  2940. opacity: 0.05,
  2941. cursor: 'wait'
  2942. }
  2943. });
  2944. },
  2945. // wrapper function to un-block element(finish loading)
  2946. unblockUI: function (el) {
  2947. jQuery(el).unblock({
  2948. onUnblock: function () {
  2949. jQuery(el).removeAttr("style");
  2950. }
  2951. });
  2952. },
  2953. };
  2954. }();
  2955. (function (a, b) {
  2956. a.fn.admin_tree = function (d) {
  2957. var c = {
  2958. "open-icon": "fa fa-folder-open",
  2959. "close-icon": "fa fa-folder",
  2960. selectable: true,
  2961. "selected-icon": "fa fa-check",
  2962. "unselected-icon": "tree-dot"
  2963. };
  2964. c = a.extend({}, c, d);
  2965. this.each(function () {
  2966. var e = a(this);
  2967. e.html('<div class = "tree-folder" style="display:none;"> <div class="tree-folder-header"> <i class="' + c["close-icon"] + '"></i> <div class="tree-folder-name"></div> </div> <div class="tree-folder-content"></div> <div class="tree-loader" style="display:none"></div> </div> <div class="tree-item" style="display:none;"> ' + (c["unselected-icon"] == null ? "" : '<i class="' + c["unselected-icon"] + '"></i>') + ' <div class="tree-item-name"></div> </div>');
  2968. e.addClass(c.selectable == true ? "tree-selectable" : "tree-unselectable");
  2969. e.tree(c)
  2970. });
  2971. return this
  2972. }
  2973. })(window.jQuery);
  2974. (function () {
  2975. this.Theme = (function () {
  2976. function Theme() {}
  2977. Theme.colors = {
  2978. white: "#FFFFFF",
  2979. primary: "#5E87B0",
  2980. red: "#D9534F",
  2981. green: "#A8BC7B",
  2982. blue: "#70AFC4",
  2983. orange: "#F0AD4E",
  2984. yellow: "#FCD76A",
  2985. gray: "#6B787F",
  2986. lightBlue: "#D4E5DE",
  2987. purple: "#A696CE",
  2988. pink: "#DB5E8C",
  2989. dark_orange: "#F38630"
  2990. };
  2991. return Theme;
  2992. })();
  2993. })(window.jQuery);