script.js 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790
  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 adminUrl = '/admin/';
  9. /*-----------------------------------------------------------------------------------*/
  10. /* admin login
  11. /*-----------------------------------------------------------------------------------*/
  12. var handleLogin = function () {
  13. $("#adminLoginSub").click(function(){
  14. $.ajax({
  15. cache: true,
  16. type: "POST",
  17. url: adminUrl + "adminLogin/",
  18. data:$('#adminLoginForm').serialize(),
  19. async: false,
  20. error: function(request) {
  21. alert("Connection error");
  22. },
  23. success: function(data) {
  24. if(data)
  25. location.href = adminUrl;
  26. else
  27. bootbox.alert("用户名密码错误,请重新输入");
  28. }
  29. });
  30. });
  31. }
  32. /*-----------------------------------------------------------------------------------*/
  33. /* admin uesrEdit
  34. /*-----------------------------------------------------------------------------------*/
  35. var handleUploadAvatar = function () {
  36. // var upload_path = "http://127.0.0.1/usky/uploads/avatar";
  37. var upload_path = "http://www.usky.cn/uploads/avatar";
  38. $("#fileupload").click(function(){
  39. $(this).fileupload({
  40. url : adminUrl + 'upload/uploadAvatar',
  41. dataType: 'json',
  42. done: function (e, data) {
  43. $.each(data.result.files, function (index, file) {
  44. $('#img').val(upload_path+'/'+file.name);
  45. });
  46. }
  47. });
  48. });
  49. }
  50. /*-----------------------------------------------------------------------------------*/
  51. /* admin uesrEdit
  52. /*-----------------------------------------------------------------------------------*/
  53. var handleUploadLogo = function () {
  54. // var upload_path = "http://127.0.0.1/usky/uploads/logo";
  55. var upload_path = "http://www.usky.cn/uploads/logo";
  56. $("#fileupload").each(function(){
  57. $(this).click(function(){
  58. $(this).fileupload({
  59. url : adminUrl + 'upload/uploadLogo',
  60. dataType: 'json',
  61. done: function (e, data) {
  62. $.each(data.result.files, function (index, file) {
  63. $('#img').val(upload_path+'/'+file.name);
  64. });
  65. }
  66. });
  67. });
  68. });
  69. }
  70. /*-----------------------------------------------------------------------------------*/
  71. /* admin uesrEdit
  72. /*-----------------------------------------------------------------------------------*/
  73. var handleUploadSlider = function () {
  74. // var upload_path = "http://127.0.0.1/usky/uploads/avatar";
  75. var upload_path = "http://www.usky.cn/uploads/avatar";
  76. $(".fileupload").each(function(){
  77. $(this).click(function(){
  78. var oImg = $(this).parent().parent().find(".cover");
  79. $(this).fileupload({
  80. url : adminUrl + 'upload/uploadAvatar',
  81. dataType: 'json',
  82. done: function (e, data) {
  83. $.each(data.result.files, function (index, file) {
  84. oImg.val(upload_path+'/'+file.name);
  85. });
  86. }
  87. });
  88. });
  89. });
  90. }
  91. /*-----------------------------------------------------------------------------------*/
  92. /* admin uesrEdit
  93. /*-----------------------------------------------------------------------------------*/
  94. var handleUploadPdf = function () {
  95. $("#fileupload").each(function(){
  96. $(this).click(function(){
  97. $(this).fileupload({
  98. url : adminUrl + 'upload/uploadFile',
  99. dataType: 'json',
  100. done: function (e, data) {
  101. $.each(data.result.files, function (index, file) {
  102. $('#img').val(file.name);
  103. });
  104. },
  105. progressall: function (e, data) {
  106. var progress = parseInt(data.loaded / data.total * 100, 10);
  107. $('#progress1').css(
  108. 'width',
  109. progress + '%'
  110. );
  111. if (progress==100) {
  112. setInterval(function() {
  113. $('#progress1').css(
  114. 'width',
  115. '0%'
  116. );
  117. },1000);
  118. }
  119. }
  120. });
  121. });
  122. });
  123. }
  124. /*-----------------------------------------------------------------------------------*/
  125. /* admin handleUserModifyPass
  126. /*-----------------------------------------------------------------------------------*/
  127. var handleUserModifyPass = function () {
  128. $("#fileupload").click(function(){
  129. $(this).fileupload({
  130. url : adminUrl + 'upload/uploadAvatar',
  131. dataType: 'json',
  132. done: function (e, data) {
  133. $.each(data.result.files, function (index, file) {
  134. $('#adImg').val(upload_path+'/'+file.name);
  135. });
  136. }
  137. });
  138. });
  139. }
  140. /*-----------------------------------------------------------------------------------*/
  141. /* 添加首页合作伙伴LOGO
  142. /*-----------------------------------------------------------------------------------*/
  143. // var addHomepageLogo = function () {
  144. // $('#addHomepageLogo').click(function(){
  145. // var msg = $("#addHomepageLogoHtml").html();
  146. // bootbox.dialog({
  147. // message: msg,
  148. // title: '添加合作伙伴',
  149. // size: 'large'
  150. // })
  151. // });
  152. // }
  153. /*-----------------------------------------------------------------------------------*/
  154. /* Runs callback functions set by App.addResponsiveFunction()
  155. /*-----------------------------------------------------------------------------------*/
  156. var runResponsiveFunctions = function () {
  157. // reinitialize other subscribed elements
  158. for (var i in responsiveFunctions) {
  159. var each = responsiveFunctions[i];
  160. each.call();
  161. }
  162. }
  163. /*-----------------------------------------------------------------------------------*/
  164. /* To get the correct viewport width based on http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/
  165. /*-----------------------------------------------------------------------------------*/
  166. var getViewPort = function () {
  167. var e = window, a = 'inner';
  168. if (!('innerWidth' in window)) {
  169. a = 'client';
  170. e = document.documentElement || document.body;
  171. }
  172. return {
  173. width: e[a + 'Width'],
  174. height: e[a + 'Height']
  175. }
  176. }
  177. /*-----------------------------------------------------------------------------------*/
  178. /* Check layout size
  179. /*-----------------------------------------------------------------------------------*/
  180. var checkLayout = function() {
  181. //Check if sidebar has mini-menu
  182. is_mini_menu = $('#sidebar').hasClass('mini-menu');
  183. //Check if fixed header is activated
  184. is_fixed_header = $('#header').hasClass('navbar-fixed-top');
  185. }
  186. /*-----------------------------------------------------------------------------------*/
  187. /* Sidebar & Main Content size match
  188. /*-----------------------------------------------------------------------------------*/
  189. var handleSidebarAndContentHeight = function () {
  190. var content = $('#content');
  191. var sidebar = $('#sidebar');
  192. var body = $('body');
  193. var height;
  194. if (body.hasClass('sidebar-fixed')) {
  195. height = $(window).height() - $('#header').height() + 1;
  196. } else {
  197. height = sidebar.height() + 20;
  198. }
  199. if (height >= content.height()) {
  200. content.attr('style', 'min-height:' + height + 'px !important');
  201. }
  202. }
  203. /*-----------------------------------------------------------------------------------*/
  204. /* Sidebar
  205. /*-----------------------------------------------------------------------------------*/
  206. var handleSidebar = function () {
  207. jQuery('.sidebar-menu .has-sub > a').click(function () {
  208. var last = jQuery('.has-sub.open', $('.sidebar-menu'));
  209. last.removeClass("open");
  210. jQuery('.arrow', last).removeClass("open");
  211. jQuery('.sub', last).slideUp(200);
  212. var thisElement = $(this);
  213. var slideOffeset = -200;
  214. var slideSpeed = 200;
  215. var sub = jQuery(this).next();
  216. if (sub.is(":visible")) {
  217. jQuery('.arrow', jQuery(this)).removeClass("open");
  218. jQuery(this).parent().removeClass("open");
  219. sub.slideUp(slideSpeed, function () {
  220. if ($('#sidebar').hasClass('sidebar-fixed') == false) {
  221. App.scrollTo(thisElement, slideOffeset);
  222. }
  223. handleSidebarAndContentHeight();
  224. });
  225. } else {
  226. jQuery('.arrow', jQuery(this)).addClass("open");
  227. jQuery(this).parent().addClass("open");
  228. sub.slideDown(slideSpeed, function () {
  229. if ($('#sidebar').hasClass('sidebar-fixed') == false) {
  230. App.scrollTo(thisElement, slideOffeset);
  231. }
  232. handleSidebarAndContentHeight();
  233. });
  234. }
  235. });
  236. // Handle sub-sub menus
  237. jQuery('.sidebar-menu .has-sub .sub .has-sub-sub > a').click(function () {
  238. var last = jQuery('.has-sub-sub.open', $('.sidebar-menu'));
  239. last.removeClass("open");
  240. jQuery('.arrow', last).removeClass("open");
  241. jQuery('.sub', last).slideUp(200);
  242. var sub = jQuery(this).next();
  243. if (sub.is(":visible")) {
  244. jQuery('.arrow', jQuery(this)).removeClass("open");
  245. jQuery(this).parent().removeClass("open");
  246. sub.slideUp(200);
  247. } else {
  248. jQuery('.arrow', jQuery(this)).addClass("open");
  249. jQuery(this).parent().addClass("open");
  250. sub.slideDown(200);
  251. }
  252. });
  253. }
  254. /*-----------------------------------------------------------------------------------*/
  255. /* Collapse Sidebar Programatically
  256. /*-----------------------------------------------------------------------------------*/
  257. var collapseSidebar = function () {
  258. var iconElem = document.getElementById("sidebar-collapse").querySelector('[class*="fa-"]');
  259. var iconLeft = iconElem.getAttribute("data-icon1");
  260. var iconRight = iconElem.getAttribute("data-icon2");
  261. /* For Navbar */
  262. jQuery('.navbar-brand').addClass("mini-menu");
  263. /* For sidebar */
  264. jQuery('#sidebar').addClass("mini-menu");
  265. jQuery('#main-content').addClass("margin-left-50");
  266. jQuery('.sidebar-collapse i').removeClass(iconLeft);
  267. jQuery('.sidebar-collapse i').addClass(iconRight);
  268. /* Remove placeholder from Search Bar */
  269. jQuery('.search').attr('placeholder', '');
  270. collapsed = true;
  271. /* Set a cookie so that mini-sidebar persists */
  272. $.cookie('mini_sidebar', '1');
  273. }
  274. /*-----------------------------------------------------------------------------------*/
  275. /* Responsive Sidebar Collapse
  276. /*-----------------------------------------------------------------------------------*/
  277. var responsiveSidebar = function () {
  278. //Handle sidebar collapse on screen width
  279. var width = $(window).width();
  280. if ( width < 768 ) {
  281. is_mobile = true;
  282. //Hide the sidebar completely
  283. jQuery('#main-content').addClass("margin-left-0");
  284. }
  285. else {
  286. is_mobile = false;
  287. //Show the sidebar completely
  288. jQuery('#main-content').removeClass("margin-left-0");
  289. var menu = $('.sidebar');
  290. if (menu.parent('.slimScrollDiv').size() === 1) { // destroy existing instance before resizing
  291. menu.slimScroll({
  292. destroy: true
  293. });
  294. menu.removeAttr('style');
  295. $('#sidebar').removeAttr('style');
  296. }
  297. }
  298. }
  299. /*-----------------------------------------------------------------------------------*/
  300. /* Sidebar Collapse
  301. /*-----------------------------------------------------------------------------------*/
  302. var handleSidebarCollapse = function () {
  303. var viewport = getViewPort();
  304. if ($.cookie('mini_sidebar') === '1') {
  305. /* For Navbar */
  306. jQuery('.navbar-brand').addClass("mini-menu");
  307. /* For sidebar */
  308. jQuery('#sidebar').addClass("mini-menu");
  309. jQuery('#main-content').addClass("margin-left-50");
  310. collapsed = true;
  311. }
  312. //Handle sidebar collapse on user interaction
  313. jQuery('.sidebar-collapse').click(function () {
  314. //Handle mobile sidebar toggle
  315. if(is_mobile && !(is_mini_menu)){
  316. //If sidebar is collapsed
  317. if(collapsed){
  318. jQuery('body').removeClass("slidebar");
  319. jQuery('.sidebar').removeClass("sidebar-fixed");
  320. //Add fixed top nav if exists
  321. if(is_fixed_header) {
  322. jQuery('#header').addClass("navbar-fixed-top");
  323. jQuery('#main-content').addClass("margin-top-100");
  324. }
  325. collapsed = false;
  326. $.cookie('mini_sidebar', '0');
  327. }
  328. else {
  329. jQuery('body').addClass("slidebar");
  330. jQuery('.sidebar').addClass("sidebar-fixed");
  331. //Remove fixed top nav if exists
  332. if(is_fixed_header) {
  333. jQuery('#header').removeClass("navbar-fixed-top");
  334. jQuery('#main-content').removeClass("margin-top-100");
  335. }
  336. collapsed = true;
  337. $.cookie('mini_sidebar', '1');
  338. handleMobileSidebar();
  339. }
  340. }
  341. else { //Handle regular sidebar toggle
  342. var iconElem = document.getElementById("sidebar-collapse").querySelector('[class*="fa-"]');
  343. var iconLeft = iconElem.getAttribute("data-icon1");
  344. var iconRight = iconElem.getAttribute("data-icon2");
  345. //If sidebar is collapsed
  346. if(collapsed){
  347. /* For Navbar */
  348. jQuery('.navbar-brand').removeClass("mini-menu");
  349. /* For sidebar */
  350. jQuery('#sidebar').removeClass("mini-menu");
  351. jQuery('#main-content').removeClass("margin-left-50");
  352. jQuery('.sidebar-collapse i').removeClass(iconRight);
  353. jQuery('.sidebar-collapse i').addClass(iconLeft);
  354. /* Add placeholder from Search Bar */
  355. jQuery('.search').attr('placeholder', "Search");
  356. collapsed = false;
  357. $.cookie('mini_sidebar', '0');
  358. }
  359. else {
  360. /* For Navbar */
  361. jQuery('.navbar-brand').addClass("mini-menu");
  362. /* For sidebar */
  363. jQuery('#sidebar').addClass("mini-menu");
  364. jQuery('#main-content').addClass("margin-left-50");
  365. jQuery('.sidebar-collapse i').removeClass(iconLeft);
  366. jQuery('.sidebar-collapse i').addClass(iconRight);
  367. /* Remove placeholder from Search Bar */
  368. jQuery('.search').attr('placeholder', '');
  369. collapsed = true;
  370. $.cookie('mini_sidebar', '1');
  371. }
  372. $("#main-content").on('resize', function (e) {
  373. e.stopPropagation();
  374. });
  375. }
  376. });
  377. }
  378. /*-----------------------------------------------------------------------------------*/
  379. /* Handle Fixed Sidebar on Mobile devices
  380. /*-----------------------------------------------------------------------------------*/
  381. var handleMobileSidebar = function () {
  382. var menu = $('.sidebar');
  383. if (menu.parent('.slimScrollDiv').size() === 1) { // destroy existing instance before updating the height
  384. menu.slimScroll({
  385. destroy: true
  386. });
  387. menu.removeAttr('style');
  388. $('#sidebar').removeAttr('style');
  389. }
  390. menu.slimScroll({
  391. size: '7px',
  392. color: '#a1b2bd',
  393. opacity: .3,
  394. height: "100%",
  395. allowPageScroll: false,
  396. disableFadeOut: false
  397. });
  398. }
  399. /*-----------------------------------------------------------------------------------*/
  400. /* Handle Fixed Sidebar
  401. /*-----------------------------------------------------------------------------------*/
  402. var handleFixedSidebar = function () {
  403. var menu = $('.sidebar-menu');
  404. if (menu.parent('.slimScrollDiv').size() === 1) { // destroy existing instance before updating the height
  405. menu.slimScroll({
  406. destroy: true
  407. });
  408. menu.removeAttr('style');
  409. $('#sidebar').removeAttr('style');
  410. }
  411. if ($('.sidebar-fixed').size() === 0) {
  412. handleSidebarAndContentHeight();
  413. return;
  414. }
  415. var viewport = getViewPort();
  416. if (viewport.width >= 992) {
  417. var sidebarHeight = $(window).height() - $('#header').height() + 1;
  418. menu.slimScroll({
  419. size: '7px',
  420. color: '#a1b2bd',
  421. opacity: .3,
  422. height: sidebarHeight,
  423. allowPageScroll: false,
  424. disableFadeOut: false
  425. });
  426. handleSidebarAndContentHeight();
  427. }
  428. }
  429. /*-----------------------------------------------------------------------------------*/
  430. /* Windows Resize function
  431. /*-----------------------------------------------------------------------------------*/
  432. jQuery(window).resize(function() {
  433. setTimeout(function () {
  434. checkLayout();
  435. handleSidebarAndContentHeight();
  436. responsiveSidebar();
  437. handleFixedSidebar();
  438. handleNavbarFixedTop();
  439. runResponsiveFunctions();
  440. }, 50); // wait 50ms until window resize finishes.
  441. });
  442. /*-----------------------------------------------------------------------------------*/
  443. /* Date Range Picker
  444. /*-----------------------------------------------------------------------------------*/
  445. // var handleDateTimePickers = function () {
  446. // $('#reportrange').daterangepicker(
  447. // {
  448. // startDate: moment().subtract('days', 29),
  449. // endDate: moment(),
  450. // minDate: '01/01/2012',
  451. // maxDate: '12/31/2014',
  452. // dateLimit: { days: 60 },
  453. // showDropdowns: true,
  454. // showWeekNumbers: true,
  455. // timePicker: false,
  456. // timePickerIncrement: 1,
  457. // timePicker12Hour: true,
  458. // ranges: {
  459. // 'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)],
  460. // 'Last 30 Days': [moment().subtract('days', 29), moment()],
  461. // 'This Month': [moment().startOf('month'), moment().endOf('month')]
  462. // },
  463. // opens: 'left',
  464. // buttonClasses: ['btn btn-default'],
  465. // applyClass: 'btn-small btn-primary',
  466. // cancelClass: 'btn-small',
  467. // format: 'MM/DD/YYYY',
  468. // separator: ' to ',
  469. // locale: {
  470. // applyLabel: 'Submit',
  471. // fromLabel: 'From',
  472. // toLabel: 'To',
  473. // customRangeLabel: 'Custom Range',
  474. // daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'],
  475. // monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  476. // firstDay: 1
  477. // }
  478. // },
  479. // function(start, end) {
  480. // console.log("Callback has been called!");
  481. // $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
  482. // }
  483. // );
  484. // //Set the initial state of the picker label
  485. // $('#reportrange span').html('Custom');
  486. // }
  487. /*-----------------------------------------------------------------------------------*/
  488. /* Team View
  489. /*-----------------------------------------------------------------------------------*/
  490. var handleTeamView = function () {
  491. c();
  492. $(".team-status-toggle").click(function (y) {
  493. y.preventDefault();
  494. w(this);
  495. $(this).parent().toggleClass("open");
  496. var z = x(this);
  497. $(z).slideToggle(200, function () {
  498. $(this).toggleClass("open")
  499. })
  500. });
  501. $("body").click(function (z) {
  502. var y = z.target.className.split(" ");
  503. 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) {
  504. w()
  505. }
  506. });
  507. $(".team-status #teamslider").each(function () {
  508. $(this).slimScrollHorizontal({
  509. width: "100%",
  510. alwaysVisible: true,
  511. color: "#fff",
  512. opacity: "0.5",
  513. size: "5px"
  514. })
  515. });
  516. var w = function (y) {
  517. $(".team-status").each(function () {
  518. var z = $(this);
  519. if (z.is(":visible")) {
  520. var A = x(y);
  521. if (A != ("#" + z.attr("id"))) {
  522. $(this).slideUp(200, function () {
  523. $(this).toggleClass("open");
  524. $(".team-status-toggle").each(function () {
  525. var B = x(this);
  526. if (B == ("#" + z.attr("id"))) {
  527. $(this).parent().removeClass("open")
  528. }
  529. })
  530. })
  531. }
  532. }
  533. })
  534. };
  535. var x = function (y) {
  536. var z = $(y).data("teamStatus");
  537. if (typeof z == "undefined") {
  538. z = "#team-status"
  539. }
  540. return z
  541. }
  542. }
  543. var c = function () {
  544. $(".team-status").each(function () {
  545. var x = $(this);
  546. x.css("position", "absolute").css("margin-top", "-1000px").show();
  547. var w = 0;
  548. $("ul li", this).each(function () {
  549. w += $(this).outerWidth(true) + 15
  550. });
  551. x.css("position", "relative").css("margin-top", "0").hide();
  552. $("ul", this).width(w)
  553. })
  554. };
  555. /*-----------------------------------------------------------------------------------*/
  556. /* Homepage tooltips
  557. /*-----------------------------------------------------------------------------------*/
  558. var handleHomePageTooltips = function () {
  559. //On Hover
  560. //Default tooltip (Top)
  561. $('.tip').tooltip();
  562. //Bottom tooltip
  563. $('.tip-bottom').tooltip({
  564. placement : 'bottom'
  565. });
  566. //Left tooltip
  567. $('.tip-left').tooltip({
  568. placement : 'left'
  569. });
  570. //Right tooltip
  571. $('.tip-right').tooltip({
  572. placement : 'right'
  573. });
  574. //On Focus
  575. //Default tooltip (Top)
  576. $('.tip-focus').tooltip({
  577. trigger: 'focus'
  578. });
  579. }
  580. /*-----------------------------------------------------------------------------------*/
  581. /* Box tools
  582. /*-----------------------------------------------------------------------------------*/
  583. var handleBoxTools = function () {
  584. //Collapse
  585. jQuery('.box .tools .collapse, .box .tools .expand').click(function () {
  586. var el = jQuery(this).parents(".box").children(".box-body");
  587. if (jQuery(this).hasClass("collapse")) {
  588. jQuery(this).removeClass("collapse").addClass("expand");
  589. var i = jQuery(this).children(".fa-chevron-up");
  590. i.removeClass("fa-chevron-up").addClass("fa-chevron-down");
  591. el.slideUp(200);
  592. } else {
  593. jQuery(this).removeClass("expand").addClass("collapse");
  594. var i = jQuery(this).children(".fa-chevron-down");
  595. i.removeClass("fa-chevron-down").addClass("fa-chevron-up");
  596. el.slideDown(200);
  597. }
  598. });
  599. /* Close */
  600. jQuery('.box .tools a.remove').click(function () {
  601. var removable = jQuery(this).parents(".box");
  602. if (removable.next().hasClass('box') || removable.prev().hasClass('box')) {
  603. jQuery(this).parents(".box").remove();
  604. } else {
  605. jQuery(this).parents(".box").parent().remove();
  606. }
  607. });
  608. /* Reload */
  609. jQuery('.box .tools a.reload').click(function () {
  610. var el = jQuery(this).parents(".box");
  611. App.blockUI(el);
  612. window.setTimeout(function () {
  613. App.unblockUI(el);
  614. }, 1000);
  615. });
  616. }
  617. /*-----------------------------------------------------------------------------------*/
  618. /* SlimScroll
  619. /*-----------------------------------------------------------------------------------*/
  620. var handleSlimScrolls = function () {
  621. if (!jQuery().slimScroll) {
  622. return;
  623. }
  624. $('.scroller').each(function () {
  625. $(this).slimScroll({
  626. size: '7px',
  627. color: '#a1b2bd',
  628. height: $(this).attr("data-height"),
  629. alwaysVisible: ($(this).attr("data-always-visible") == "1" ? true : false),
  630. railVisible: ($(this).attr("data-rail-visible") == "1" ? true : false),
  631. railOpacity: 0.1,
  632. disableFadeOut: true
  633. });
  634. });
  635. }
  636. /*-----------------------------------------------------------------------------------*/
  637. /* Bootbox alerts
  638. /*-----------------------------------------------------------------------------------*/
  639. var handleBootbox = function () {
  640. $(".basic-alert").click(function(){
  641. bootbox.alert("Hello World111111");
  642. });
  643. $(".confirm-dialog").click(function(){
  644. bootbox.confirm("Are you sure?", function(result){});
  645. });
  646. $(".multiple-buttons").click(function(){
  647. bootbox.dialog({
  648. message: "I am a custom dialog",
  649. title: "Custom title",
  650. buttons: {
  651. success: {
  652. label: "Success!",
  653. className: "btn-success",
  654. callback: function() {
  655. Example.show("great success");
  656. }
  657. },
  658. danger: {
  659. label: "Danger!",
  660. className: "btn-danger",
  661. callback: function() {
  662. Example.show("uh oh, look out!");
  663. }
  664. },
  665. main: {
  666. label: "Click ME!",
  667. className: "btn-primary",
  668. callback: function() {
  669. Example.show("Primary button");
  670. }
  671. }
  672. }
  673. });
  674. });
  675. $(".multiple-dialogs").click(function(){
  676. bootbox.alert("In 1 second a new modal will open");
  677. setTimeout(function() {
  678. bootbox.dialog({
  679. message: "Will you purchase this awesome theme",
  680. title: "Pop quiz",
  681. buttons: {
  682. success: {
  683. label: "Yes!",
  684. className: "btn-success",
  685. callback: function() {
  686. bootbox.alert("Congratulations! You made the right decision.", function(){
  687. $(".bootbox").modal("hide");
  688. });
  689. }
  690. },
  691. danger: {
  692. label: "No!",
  693. className: "btn-danger",
  694. callback: function() {
  695. bootbox.alert("Oops, we're sorry to hear that!", function(){
  696. $(".bootbox").modal("hide");
  697. });
  698. }
  699. },
  700. main: {
  701. label: "Click ME!",
  702. className: "btn-primary",
  703. callback: function() {
  704. bootbox.alert("Hello World", function(){
  705. $(".bootbox").modal("hide");
  706. });
  707. }
  708. }
  709. }
  710. });
  711. }, 1000);
  712. });
  713. $(".programmatic-close").click(function(){
  714. bootbox.alert("In 3 second this modal will close..");
  715. setTimeout(function() {
  716. $(".bootbox").modal("hide");
  717. }, 3000);
  718. });
  719. }
  720. /*-----------------------------------------------------------------------------------*/
  721. /* Popovers
  722. /*-----------------------------------------------------------------------------------*/
  723. var handlePopovers = function () {
  724. //Default (Right)
  725. $('.pop').popover();
  726. //Bottom
  727. $('.pop-bottom').popover({
  728. placement : 'bottom'
  729. });
  730. //Left
  731. $('.pop-left').popover({
  732. placement : 'left'
  733. });
  734. //Top
  735. $('.pop-top').popover({
  736. placement : 'top'
  737. });
  738. //Trigger hover
  739. $('.pop-hover').popover({
  740. trigger: 'hover'
  741. });
  742. }
  743. /*-----------------------------------------------------------------------------------*/
  744. /* Hubspot messenger
  745. /*-----------------------------------------------------------------------------------*/
  746. var handleMessenger = function () {
  747. //Normal
  748. $("#normal").click(function(){
  749. var mytheme = $('input[name=theme]:checked').val();
  750. var mypos = $('input[name=position]:checked').val();
  751. //Set theme
  752. Messenger.options = {
  753. extraClasses: 'messenger-fixed '+mypos,
  754. theme: mytheme
  755. }
  756. //Call
  757. Messenger().post({
  758. message:"This is a normal notification!",
  759. showCloseButton: true
  760. });
  761. });
  762. //Interactive
  763. $("#interactive").click(function(){
  764. var mytheme = $('input[name=theme]:checked').val();
  765. var mypos = $('input[name=position]:checked').val();
  766. //Set theme
  767. Messenger.options = {
  768. extraClasses: 'messenger-fixed '+mypos,
  769. theme: mytheme
  770. }
  771. var msg;
  772. msg = Messenger().post({
  773. message: 'Launching thermonuclear war...',
  774. type: 'info',
  775. actions: {
  776. cancel: {
  777. label: 'cancel launch',
  778. action: function() {
  779. return msg.update({
  780. message: 'Thermonuclear war averted',
  781. type: 'success',
  782. showCloseButton: true,
  783. actions: false
  784. });
  785. }
  786. }
  787. }
  788. });
  789. });
  790. //Timer
  791. $("#timer").click(function(){
  792. var mytheme = $('input[name=theme]:checked').val();
  793. var mypos = $('input[name=position]:checked').val();
  794. //Set theme
  795. Messenger.options = {
  796. extraClasses: 'messenger-fixed '+mypos,
  797. theme: mytheme
  798. }
  799. var i;
  800. i = 0;
  801. Messenger().run({
  802. errorMessage: 'Error destroying alien planet',
  803. successMessage: 'Alien planet destroyed!',
  804. showCloseButton: true,
  805. action: function(opts) {
  806. if (++i < 3) {
  807. return opts.error({
  808. status: 500,
  809. readyState: 0,
  810. responseText: 0
  811. });
  812. } else {
  813. return opts.success();
  814. }
  815. }
  816. });
  817. });
  818. //Prompts
  819. $("#prompts").click(function(){
  820. var mytheme = $('input[name=theme]:checked').val();
  821. var mypos = $('input[name=position]:checked').val();
  822. //Set theme
  823. Messenger.options = {
  824. extraClasses: 'messenger-fixed '+mypos,
  825. theme: mytheme
  826. }
  827. Messenger().run({
  828. successMessage: 'Data saved.',
  829. errorMessage: 'Error saving data',
  830. progressMessage: 'Saving data',
  831. showCloseButton: true,
  832. }, {
  833. url: 'http://www.example.com/data'
  834. });
  835. });
  836. }
  837. /*-----------------------------------------------------------------------------------*/
  838. /* Alerts
  839. /*-----------------------------------------------------------------------------------*/
  840. var handleAlerts = function () {
  841. $(".alert").alert();
  842. }
  843. /*-----------------------------------------------------------------------------------*/
  844. /* Magic Suggest
  845. /*-----------------------------------------------------------------------------------*/
  846. var handleMagicSuggest = function () {
  847. var jsonData = [];
  848. var cities = 'New York,Los Angeles,Chicago,Houston,Paris,Marseille,Toulouse,Lyon,Bordeaux,Philadelphia,Phoenix,San Antonio,San Diego,Dallas,San Jose,Jacksonville'.split(',');
  849. 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});
  850. var ms1 = $('#ms1').magicSuggest({
  851. data: jsonData,
  852. sortOrder: 'name',
  853. value: [0],
  854. selectionPosition: 'right',
  855. groupBy: 'status',
  856. maxDropHeight: 200
  857. });
  858. var ms2 = $('#ms2').magicSuggest({
  859. width: '80%',
  860. data: jsonData
  861. });
  862. var ms3 = $('#ms3').magicSuggest({
  863. selectionPosition: 'bottom',
  864. renderer: function(city){
  865. return '<div>' +
  866. '<div style="font-family: Arial; font-weight: bold">' + city.name + '</div>' +
  867. '<div><b>Cooooolness</b>: ' + city.coolness + '</div>' +
  868. '</div>';
  869. },
  870. minChars: 1,
  871. selectionStacked: true,
  872. data: jsonData
  873. });
  874. var ms4 = $('#ms4').magicSuggest({
  875. data: [{id:1,label:'one'}, {id:2,label:'two'}, {id:3,label:'three'}],
  876. displayField: 'label',
  877. value: [1,3]
  878. });
  879. var ms5 = $('#ms5').magicSuggest({
  880. width: '80%',
  881. 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'
  882. });
  883. var ms6 = $('#ms6').magicSuggest({
  884. // will fetch data from options
  885. });
  886. var ms7 = $('#ms7').magicSuggest({
  887. data: jsonData,
  888. resultAsString: true,
  889. maxSelection: 1,
  890. maxSelectionRenderer: function(){}
  891. })
  892. }
  893. /*-----------------------------------------------------------------------------------*/
  894. /* Timeago
  895. /*-----------------------------------------------------------------------------------*/
  896. var handleTimeAgo = function () {
  897. jQuery(document).ready(function() {
  898. var curr_time = moment().format('YYYY-MM-DD HH:mm');
  899. var yesterday = moment().subtract('days', 1).format('MMM D, YYYY');
  900. $("#curr-time").html(curr_time);
  901. $("#curr-time").attr('title', curr_time);
  902. $("#curr-time").attr('data-original-title', curr_time);
  903. $("#yesterday").html(yesterday);
  904. $("#yesterday").attr('title', yesterday);
  905. $("#yesterday").attr('data-original-title', yesterday);
  906. jQuery("abbr.timeago").timeago();
  907. });
  908. }
  909. /*-----------------------------------------------------------------------------------*/
  910. /* Init Timeago
  911. /*-----------------------------------------------------------------------------------*/
  912. var initTimeAgo = function () {
  913. jQuery("abbr.timeago").timeago();
  914. }
  915. /*-----------------------------------------------------------------------------------*/
  916. /* Date & Color Picker
  917. /*-----------------------------------------------------------------------------------*/
  918. var handleDateColorpicker = function () {
  919. $(".datepicker").datepicker();
  920. $(".inlinepicker").datepicker({
  921. inline: true,
  922. showOtherMonths: true
  923. });
  924. $(".datepicker-fullscreen").pickadate();
  925. $(".timepicker-fullscreen").pickatime();
  926. //Color picker
  927. $('.colorpicker').colorpicker();
  928. var a = $("#color-pickers")[0].style;
  929. $("#colorpicker-event").colorpicker().on("changeColor", function (b) {
  930. a.backgroundColor = b.color.toHex()
  931. });
  932. }
  933. /*-----------------------------------------------------------------------------------*/
  934. /* Raty
  935. /*-----------------------------------------------------------------------------------*/
  936. var handleRaty = function () {
  937. $.fn.raty.defaults.path = 'js/jquery-raty/img';
  938. $('#score-demo').raty({ score: 3 });
  939. $('#number-demo').raty({ number: 10 });
  940. $('#readOnly-demo').raty({ readOnly: true, score: 2 });
  941. $('#halfShow-true-demo').raty({ score: 3.26 });
  942. $('#starHalf-demo').raty({
  943. path : 'js/jquery-raty/img',
  944. half : true,
  945. starOff : 'cookie-off.png',
  946. starOn : 'cookie-on.png',
  947. starHalf: 'cookie-half.png'
  948. });
  949. $('#star-off-and-star-on-demo').raty({
  950. path : 'js/jquery-raty/img',
  951. starOff: 'off.png',
  952. starOn : 'on.png'
  953. });
  954. $('#cancel-off-and-cancel-on-demo').raty({
  955. path : 'js/jquery-raty/img',
  956. cancel : true,
  957. cancelOff: 'cancel-custom-off.png',
  958. cancelOn : 'cancel-custom-on.png',
  959. starOn : 'star-on.png',
  960. starOff : 'star-off.png'
  961. });
  962. $('#size-demo').raty({
  963. path : 'js/jquery-raty/img',
  964. cancel : true,
  965. cancelOff: 'cancel-off-big.png',
  966. cancelOn : 'cancel-on-big.png',
  967. half : true,
  968. size : 24,
  969. starHalf : 'star-half-big.png',
  970. starOff : 'star-off-big.png',
  971. starOn : 'star-on-big.png'
  972. });
  973. $('#target-div-demo').raty({
  974. cancel: true,
  975. target: '#target-div-hint'
  976. });
  977. }
  978. /*-----------------------------------------------------------------------------------*/
  979. /* Stateful buttons
  980. /*-----------------------------------------------------------------------------------*/
  981. var handleStatefulButtons = function () {
  982. $(document).ready(function(){
  983. $("#btn-load").on("click",function(){
  984. var a=$(this);
  985. a.button("loading");
  986. setTimeout(function(){
  987. a.button("reset")}
  988. ,1500)}
  989. );
  990. $("#btn-load-complete").on("click",function(){
  991. var a=$(this);
  992. a.button("loading");
  993. setTimeout(function(){
  994. a.button("complete")}
  995. ,1500)}
  996. )}
  997. );
  998. }
  999. /*-----------------------------------------------------------------------------------*/
  1000. /* Toggle buttons
  1001. /*-----------------------------------------------------------------------------------*/
  1002. var handleToggle = function () {
  1003. $('.radio1').on('switch-change', function () {
  1004. $('.radio1').bootstrapSwitch('toggleRadioState');
  1005. });
  1006. // or
  1007. $('.radio1').on('switch-change', function () {
  1008. $('.radio1').bootstrapSwitch('toggleRadioStateAllowUncheck');
  1009. });
  1010. // or
  1011. $('.radio1').on('switch-change', function () {
  1012. $('.radio1').bootstrapSwitch('toggleRadioStateAllowUncheck', false);
  1013. });
  1014. }
  1015. /*-----------------------------------------------------------------------------------*/
  1016. /* jQuery UI Sliders
  1017. /*-----------------------------------------------------------------------------------*/
  1018. var handleSliders = function () {
  1019. function repositionTooltip( e, ui ){$
  1020. var div = $(ui.handle).data("bs.tooltip").$tip[0];
  1021. var pos = $.extend({}, $(ui.handle).offset(), { width: $(ui.handle).get(0).offsetWidth,
  1022. height: $(ui.handle).get(0).offsetHeight
  1023. });
  1024. var actualWidth = div.offsetWidth;
  1025. tp = {left: pos.left + pos.width / 2 - actualWidth / 2}
  1026. $(div).offset(tp);
  1027. $(div).find(".tooltip-inner").text( ui.value );
  1028. }
  1029. $("#slider").slider({ value: 15, slide: repositionTooltip, stop: repositionTooltip });
  1030. $("#slider .ui-slider-handle:first").tooltip( {title: $("#slider").slider("value"), trigger: "manual"}).tooltip("show");
  1031. $("#slider-default").slider();
  1032. $("#slider-range").slider({
  1033. range:true,min:0,max:500,values:[75,300]
  1034. });
  1035. $("#slider-range-min").slider({
  1036. range:"min",value:37,min:1,max:700,slide:function(a,b){
  1037. $("#slider-range-min-amount").text("$"+b.value)}
  1038. });
  1039. $("#slider-range-max").slider({
  1040. range:"max",min:1,max:700,value:300,slide:function(a,b){
  1041. $("#slider-range-max-amount").text("$"+b.value)}
  1042. });
  1043. $("#slider-vertical-multiple > span").each(function(){
  1044. var a=parseInt($(this).text(),10);
  1045. $(this).empty().slider({
  1046. value:a,range:"min",animate:true,orientation:"vertical"}
  1047. )}
  1048. );
  1049. $("#slider-vertical-range-min").slider({
  1050. range:"min",value:400,min:1,max:600,orientation:"vertical"
  1051. });
  1052. $("#slider-horizontal-range-min").slider({
  1053. range:"min",value:600,min:1,max:1000
  1054. });
  1055. }
  1056. /*-----------------------------------------------------------------------------------*/
  1057. /* jQuery UI Progress
  1058. /*-----------------------------------------------------------------------------------*/
  1059. var handleProgress = function () {
  1060. $(document).ready(function(){
  1061. jQuery.fn.anim_progressbar = function (aOptions) {
  1062. // def values
  1063. var iCms = 1000;
  1064. var iMms = 60 * iCms;
  1065. var iHms = 3600 * iCms;
  1066. var iDms = 24 * 3600 * iCms;
  1067. // def options
  1068. var aDefOpts = {
  1069. start: new Date(), // now
  1070. finish: new Date().setTime(new Date().getTime() + 60 * iCms), // now + 60 sec
  1071. interval: 100
  1072. }
  1073. var aOpts = jQuery.extend(aDefOpts, aOptions);
  1074. var vPb = this;
  1075. // each progress bar
  1076. return this.each(
  1077. function() {
  1078. var iDuration = aOpts.finish - aOpts.start;
  1079. // calling original progressbar
  1080. $(vPb).children('.pbar').progressbar();
  1081. // looping process
  1082. var vInterval = setInterval(
  1083. function(){
  1084. var iLeftMs = aOpts.finish - new Date(); // left time in MS
  1085. var iElapsedMs = new Date() - aOpts.start, // elapsed time in MS
  1086. iDays = parseInt(iLeftMs / iDms), // elapsed days
  1087. iHours = parseInt((iLeftMs - (iDays * iDms)) / iHms), // elapsed hours
  1088. iMin = parseInt((iLeftMs - (iDays * iDms) - (iHours * iHms)) / iMms), // elapsed minutes
  1089. iSec = parseInt((iLeftMs - (iDays * iDms) - (iMin * iMms) - (iHours * iHms)) / iCms), // elapsed seconds
  1090. iPerc = (iElapsedMs > 0) ? iElapsedMs / iDuration * 100 : 0; // percentages
  1091. // display current positions and progress
  1092. $(vPb).children('.percent').html('<b>'+iPerc.toFixed(1)+'%</b>');
  1093. $(vPb).children('.elapsed').html(iDays+' day '+iHours+' hr : '+iMin+' min : '+iSec+' sec remaining</b>');
  1094. $(vPb).children('.pbar').children('.ui-progressbar-value').css('width', iPerc+'%');
  1095. // in case of Finish
  1096. if (iPerc >= 100) {
  1097. clearInterval(vInterval);
  1098. $(vPb).children('.percent').html('<b>100%</b>');
  1099. $(vPb).children('.elapsed').html('Completed');
  1100. }
  1101. } ,aOpts.interval
  1102. );
  1103. }
  1104. );
  1105. }
  1106. // default mode
  1107. $('#progress1').anim_progressbar();
  1108. // from second #5 till 15
  1109. var iNow = new Date().setTime(new Date().getTime() + 5 * 1000); // now plus 5 secs
  1110. var iEnd = new Date().setTime(new Date().getTime() + 15 * 1000); // now plus 15 secs
  1111. $('#progress2').anim_progressbar({start: iNow, finish: iEnd, interval: 100});
  1112. // we will just set interval of updating to 1 sec
  1113. $('#progress3').anim_progressbar({interval: 1000});
  1114. });
  1115. }
  1116. /*-----------------------------------------------------------------------------------*/
  1117. /* jQuery Knob
  1118. /*-----------------------------------------------------------------------------------*/
  1119. var handleKnobs = function () {
  1120. $(".knob").knob({
  1121. change : function (value) {
  1122. //console.log("change : " + value);
  1123. },
  1124. release : function (value) {
  1125. //console.log(this.$.attr('value'));
  1126. console.log("release : " + value);
  1127. },
  1128. cancel : function () {
  1129. console.log("cancel : ", this);
  1130. },
  1131. draw : function () {
  1132. // "tron" case
  1133. if(this.$.data('skin') == 'tron') {
  1134. var a = this.angle(this.cv) // Angle
  1135. , sa = this.staruskyle // Previous start angle
  1136. , sat = this.staruskyle // Start angle
  1137. , ea // Previous end angle
  1138. , eat = sat + a // End angle
  1139. , r = 1;
  1140. this.g.lineWidth = this.lineWidth;
  1141. this.o.cursor
  1142. && (sat = eat - 0.3)
  1143. && (eat = eat + 0.3);
  1144. if (this.o.displayPrevious) {
  1145. ea = this.staruskyle + this.angle(this.v);
  1146. this.o.cursor
  1147. && (sa = ea - 0.3)
  1148. && (ea = ea + 0.3);
  1149. this.g.beginPath();
  1150. this.g.strokeStyle = this.pColor;
  1151. this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sa, ea, false);
  1152. this.g.stroke();
  1153. }
  1154. this.g.beginPath();
  1155. this.g.strokeStyle = r ? this.o.fgColor : this.fgColor ;
  1156. this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sat, eat, false);
  1157. this.g.stroke();
  1158. this.g.lineWidth = 2;
  1159. this.g.beginPath();
  1160. this.g.strokeStyle = this.o.fgColor;
  1161. this.g.arc( this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false);
  1162. this.g.stroke();
  1163. return false;
  1164. }
  1165. }
  1166. });
  1167. }
  1168. /*-----------------------------------------------------------------------------------*/
  1169. /* Custom tabs
  1170. /*-----------------------------------------------------------------------------------*/
  1171. var handleCustomTabs = function () {
  1172. var adjustMinHeight = function (y) {
  1173. $(y).each(function () {
  1174. var A = $($($(this).attr("href")));
  1175. var z = $(this).parent().parent();
  1176. if (z.height() > A.height()) {
  1177. A.css("min-height", z.height())
  1178. }
  1179. })
  1180. };
  1181. $("body").on("click", '.nav.nav-tabs.tabs-left a[data-toggle="tab"], .nav.nav-tabs.tabs-right a[data-toggle="tab"]', function () {
  1182. adjustMinHeight($(this))
  1183. });
  1184. adjustMinHeight('.nav.nav-tabs.tabs-left > li.active > a[data-toggle="tab"], .nav.nav-tabs.tabs-right > li.active > a[data-toggle="tab"]');
  1185. if (location.hash) {
  1186. var w = location.hash.substr(1);
  1187. $('a[href="#' + w + '"]').click()
  1188. }
  1189. }
  1190. /*-----------------------------------------------------------------------------------*/
  1191. /* Fuel UX Tree
  1192. /*-----------------------------------------------------------------------------------*/
  1193. var handleTree = function () {
  1194. $('#tree1').admin_tree({
  1195. dataSource: treeDataSource ,
  1196. multiSelect:true,
  1197. loadingHTML:'<div class="tree-loading"><i class="fa fa-spinner fa-2x fa-spin"></i></div>',
  1198. 'open-icon' : 'fa-minus',
  1199. 'close-icon' : 'fa-plus',
  1200. 'selectable' : true,
  1201. 'selected-icon' : 'fa-check',
  1202. 'unselected-icon' : 'fa-times'
  1203. });
  1204. $('#tree3').admin_tree({
  1205. dataSource: treeDataSource3 ,
  1206. multiSelect:true,
  1207. loadingHTML:'<div class="tree-loading"><i class="fa fa-spinner fa-2x fa-spin"></i></div>',
  1208. 'open-icon' : 'fa-minus-square',
  1209. 'close-icon' : 'fa-plus-square',
  1210. 'selectable' : true,
  1211. 'selected-icon' : 'fa-check',
  1212. 'unselected-icon' : 'fa-times'
  1213. });
  1214. $('#tree2').admin_tree({
  1215. dataSource: treeDataSource2 ,
  1216. loadingHTML:'<div class="tree-loading"><i class="fa fa-spinner fa-2x fa-spin"></i></div>',
  1217. 'open-icon' : 'fa-folder-open',
  1218. 'close-icon' : 'fa-folder',
  1219. 'selectable' : false,
  1220. 'selected-icon' : null,
  1221. 'unselected-icon' : null
  1222. });
  1223. //To add font awesome support
  1224. $('.tree').find('[class*="fa-"]').addClass("fa");
  1225. }
  1226. /*-----------------------------------------------------------------------------------*/
  1227. /* Nestable Lists
  1228. /*-----------------------------------------------------------------------------------*/
  1229. var handleNestableLists = function () {
  1230. var updateOutput = function(e)
  1231. {
  1232. var list = e.length ? e : $(e.target),
  1233. output = list.data('output');
  1234. if (window.JSON) {
  1235. output.val(window.JSON.stringify(list.nestable('serialize')));//, null, 2));
  1236. } else {
  1237. output.val('JSON browser support required for this demo.');
  1238. }
  1239. };
  1240. // activate Nestable for list 1
  1241. $('#nestable').nestable({
  1242. group: 1
  1243. })
  1244. .on('change', updateOutput);
  1245. // activate Nestable for list 2
  1246. $('#nestable2').nestable({
  1247. group: 1
  1248. })
  1249. .on('change', updateOutput);
  1250. // output initial serialised data
  1251. updateOutput($('#nestable').data('output', $('#nestable-output')));
  1252. updateOutput($('#nestable2').data('output', $('#nestable2-output')));
  1253. $('#nestable-menu').on('click', function(e)
  1254. {
  1255. var target = $(e.target),
  1256. action = target.data('action');
  1257. if (action === 'expand-all') {
  1258. $('.dd').nestable('expandAll');
  1259. }
  1260. if (action === 'collapse-all') {
  1261. $('.dd').nestable('collapseAll');
  1262. }
  1263. });
  1264. $('#nestable3').nestable();
  1265. }
  1266. /*-----------------------------------------------------------------------------------*/
  1267. /* Table Cloth
  1268. /*-----------------------------------------------------------------------------------*/
  1269. var handleTablecloth = function () {
  1270. $("#example-dark").tablecloth({
  1271. theme: "dark"
  1272. });
  1273. $("#example-paper").tablecloth({
  1274. theme:"paper",
  1275. striped: true
  1276. });
  1277. $("#example-stats").tablecloth({
  1278. theme:"stats",
  1279. sortable:true,
  1280. condensed:true,
  1281. striped:true,
  1282. clean:true
  1283. });
  1284. }
  1285. /*-----------------------------------------------------------------------------------*/
  1286. /* Data Tables
  1287. /*-----------------------------------------------------------------------------------*/
  1288. var handleDataTables = function () {
  1289. $('#logotable').dataTable({
  1290. "aaSorting": [[ 0, "asc" ]],
  1291. "aoColumnDefs": [
  1292. {
  1293. 'sWidth': '5%',
  1294. "aTargets": [0]
  1295. },
  1296. {
  1297. 'sWidth': '10%',
  1298. "aTargets": [1]
  1299. },
  1300. {
  1301. 'sWidth': '60%',
  1302. "aTargets": [2]
  1303. },
  1304. {
  1305. 'sWidth': '25%',
  1306. "aTargets": [3]
  1307. }
  1308. ],
  1309. "sPaginationType": "bs_full",
  1310. "oLanguage": {
  1311. "sLengthMenu": "每页显示 _MENU_ 条记录",
  1312. "sZeroRecords": "抱歉, 没有找到",
  1313. "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
  1314. "sInfoEmpty": "没有数据",
  1315. "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
  1316. "oPaginate": {
  1317. "sFirst": "首页",
  1318. "sPrevious": "前一页",
  1319. "sNext": "后一页",
  1320. "sLast": "尾页"
  1321. }
  1322. }
  1323. });
  1324. $('#datatable').dataTable({
  1325. "aaSorting": [[ 0, "asc" ]],
  1326. "sPaginationType": "bs_full",
  1327. "oLanguage": {
  1328. "sLengthMenu": "每页显示 _MENU_ 条记录",
  1329. "sZeroRecords": "抱歉, 没有找到",
  1330. "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
  1331. "sInfoEmpty": "没有数据",
  1332. "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
  1333. "oPaginate": {
  1334. "sFirst": "首页",
  1335. "sPrevious": "前一页",
  1336. "sNext": "后一页",
  1337. "sLast": "尾页"
  1338. }
  1339. }
  1340. });
  1341. $('.datatable').each(function(){
  1342. var datatable = $(this);
  1343. // SEARCH - Add the placeholder for Search and Turn this into in-line form control
  1344. var search_input = datatable.closest('.dataTables_wrapper').find('div[id$=_filter] input');
  1345. search_input.attr('placeholder', 'Search');
  1346. search_input.addClass('form-control input-sm');
  1347. // LENGTH - Inline-Form control
  1348. var length_sel = datatable.closest('.dataTables_wrapper').find('div[id$=_length] select');
  1349. length_sel.addClass('form-control input-sm');
  1350. });
  1351. }
  1352. var handleExampleTables = function () {
  1353. $('#exampletable').dataTable({
  1354. "aaSorting": [[ 0, "asc" ]],
  1355. "aoColumnDefs": [
  1356. {
  1357. 'sWidth': '5%',
  1358. "aTargets": [0]
  1359. },
  1360. {
  1361. 'sWidth': '10%',
  1362. "aTargets": [1]
  1363. },
  1364. {
  1365. 'sWidth': '30%',
  1366. "aTargets": [2]
  1367. },
  1368. {
  1369. 'sWidth': '35%',
  1370. "aTargets": [3]
  1371. },
  1372. {
  1373. 'sWidth': '20%',
  1374. "aTargets": [4]
  1375. }
  1376. ],
  1377. "sPaginationType": "bs_full",
  1378. "oLanguage": {
  1379. "sLengthMenu": "每页显示 _MENU_ 条记录",
  1380. "sZeroRecords": "抱歉, 没有找到",
  1381. "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
  1382. "sInfoEmpty": "没有数据",
  1383. "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
  1384. "oPaginate": {
  1385. "sFirst": "首页",
  1386. "sPrevious": "前一页",
  1387. "sNext": "后一页",
  1388. "sLast": "尾页"
  1389. }
  1390. }
  1391. });
  1392. $('.datatable').each(function(){
  1393. var datatable = $(this);
  1394. // SEARCH - Add the placeholder for Search and Turn this into in-line form control
  1395. var search_input = datatable.closest('.dataTables_wrapper').find('div[id$=_filter] input');
  1396. search_input.attr('placeholder', 'Search');
  1397. search_input.addClass('form-control input-sm');
  1398. // LENGTH - Inline-Form control
  1399. var length_sel = datatable.closest('.dataTables_wrapper').find('div[id$=_length] select');
  1400. length_sel.addClass('form-control input-sm');
  1401. });
  1402. }
  1403. var handleNewsTables = function () {
  1404. $('#newstable').dataTable({
  1405. "aaSorting": [[ 2, "desc" ]],
  1406. "aoColumnDefs": [
  1407. {
  1408. 'sWidth': '10%',
  1409. "aTargets": [0]
  1410. },
  1411. {
  1412. 'sWidth': '40%',
  1413. "aTargets": [1]
  1414. },
  1415. {
  1416. 'sWidth': '30%',
  1417. "aTargets": [2]
  1418. },
  1419. {
  1420. 'sWidth': '20%',
  1421. "aTargets": [3]
  1422. }
  1423. ],
  1424. "sPaginationType": "bs_full",
  1425. "oLanguage": {
  1426. "sLengthMenu": "每页显示 _MENU_ 条记录",
  1427. "sZeroRecords": "抱歉, 没有找到",
  1428. "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
  1429. "sInfoEmpty": "没有数据",
  1430. "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
  1431. "oPaginate": {
  1432. "sFirst": "首页",
  1433. "sPrevious": "前一页",
  1434. "sNext": "后一页",
  1435. "sLast": "尾页"
  1436. }
  1437. }
  1438. });
  1439. $('.datatable').each(function(){
  1440. var datatable = $(this);
  1441. // SEARCH - Add the placeholder for Search and Turn this into in-line form control
  1442. var search_input = datatable.closest('.dataTables_wrapper').find('div[id$=_filter] input');
  1443. search_input.attr('placeholder', 'Search');
  1444. search_input.addClass('form-control input-sm');
  1445. // LENGTH - Inline-Form control
  1446. var length_sel = datatable.closest('.dataTables_wrapper').find('div[id$=_length] select');
  1447. length_sel.addClass('form-control input-sm');
  1448. });
  1449. }
  1450. /*-----------------------------------------------------------------------------------*/
  1451. /* Typeahead
  1452. /*-----------------------------------------------------------------------------------*/
  1453. var handleTypeahead = function () {
  1454. $('#autocomplete-example').typeahead({
  1455. name: 'countries',
  1456. local: ["red", "blue", "green", "yellow", "brown", "black"]
  1457. });
  1458. }
  1459. /*-----------------------------------------------------------------------------------*/
  1460. /* Autosize
  1461. /*-----------------------------------------------------------------------------------*/
  1462. var handleAutosize = function () {
  1463. $('textarea.autosize').autosize();
  1464. $('textarea.autosize').addClass('textarea-transition');
  1465. }
  1466. /*-----------------------------------------------------------------------------------*/
  1467. /* jquery Counatble
  1468. /*-----------------------------------------------------------------------------------*/
  1469. var handleCountable = function () {
  1470. $('.countable').simplyCountable();
  1471. }
  1472. /*-----------------------------------------------------------------------------------*/
  1473. /* Select2
  1474. /*-----------------------------------------------------------------------------------*/
  1475. var handleSelect2 = function () {
  1476. function movieFormatResult(movie) {
  1477. var markup = "<table class='movie-result'><tr>";
  1478. if (movie.posters !== undefined && movie.posters.thumbnail !== undefined) {
  1479. markup += "<td class='movie-image'><img src='" + movie.posters.thumbnail + "'/></td>";
  1480. }
  1481. markup += "<td class='movie-info'><div class='movie-title'>" + movie.title + "</div>";
  1482. if (movie.critics_consensus !== undefined) {
  1483. markup += "<div class='movie-synopsis'>" + movie.critics_consensus + "</div>";
  1484. }
  1485. else if (movie.synopsis !== undefined) {
  1486. markup += "<div class='movie-synopsis'>" + movie.synopsis + "</div>";
  1487. }
  1488. markup += "</td></tr></table>"
  1489. return markup;
  1490. }
  1491. function movieFormatSelection(movie) {
  1492. return movie.title;
  1493. }
  1494. /* Basic */
  1495. $("#e1").select2();
  1496. /* Multi-Value Select Boxes */
  1497. $("#e2").select2();
  1498. /* With Placeholders */
  1499. $("#e3").select2({
  1500. placeholder: "Select a State",
  1501. allowClear: true
  1502. });
  1503. /* With Placeholders */
  1504. $("#e4").select2({
  1505. placeholder: "Select a State"
  1506. });
  1507. /* Minimum Input */
  1508. $("#e5").select2({
  1509. placeholder: "Select 2 characters",
  1510. minimumInputLength: 2
  1511. });
  1512. /* Maximum Selection Size */
  1513. $("#e6").select2({
  1514. placeholder: "Select a maximum of 3 states",
  1515. maximumSelectionSize: 3
  1516. });
  1517. /* Loading Remote Data */
  1518. $("#e7").select2({
  1519. placeholder: "Search for a movie",
  1520. minimumInputLength: 1,
  1521. ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
  1522. url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
  1523. dataType: 'jsonp',
  1524. data: function (term, page) {
  1525. return {
  1526. q: term, // search term
  1527. page_limit: 10,
  1528. apikey: "uekzdmffsrmqzwdtcgmc5yu9" //please do not copy API. Use your own. Copying will be treated as a violation - usky Admin Author
  1529. };
  1530. },
  1531. results: function (data, page) { // parse the results into the format expected by Select2.
  1532. // since we are using custom formatting functions we do not need to alter remote JSON data
  1533. return {results: data.movies};
  1534. }
  1535. },
  1536. initSelection: function(element, callback) {
  1537. // the input tag has a value attribute preloaded that points to a preselected movie's id
  1538. // this function resolves that id attribute to an object that select2 can render
  1539. // using its formatResult renderer - that way the movie name is shown preselected
  1540. var id=$(element).val();
  1541. if (id!=="") {
  1542. $.ajax("http://api.rottentomatoes.com/api/public/v1.0/movies/"+id+".json", {
  1543. data: {
  1544. apikey: "uekzdmffsrmqzwdtcgmc5yu9" //please do not copy API. Use your own. Copying will be treated as a violation - usky Admin Author
  1545. },
  1546. dataType: "jsonp"
  1547. }).done(function(data) { callback(data); });
  1548. }
  1549. },
  1550. formatResult: movieFormatResult, // omitted for brevity, see the source of this page
  1551. formatSelection: movieFormatSelection, // omitted for brevity, see the source of this page
  1552. dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
  1553. escapeMarkup: function (m) { return m; } // we do not want to escape markup since we are displaying html in results
  1554. });
  1555. /* Tagging Support */
  1556. $("#e8").select2({
  1557. tags:["red", "green", "blue"]
  1558. });
  1559. }
  1560. /*-----------------------------------------------------------------------------------*/
  1561. /* Uniform
  1562. /*-----------------------------------------------------------------------------------*/
  1563. var handleUniform = function () {
  1564. $(".uniform").uniform();
  1565. }
  1566. /*-----------------------------------------------------------------------------------*/
  1567. /* All Checkboxes
  1568. /*-----------------------------------------------------------------------------------*/
  1569. var handleAllUniform = function () {
  1570. $("select, input[type='checkbox']").uniform();
  1571. }
  1572. /*-----------------------------------------------------------------------------------*/
  1573. /* BT Wysiwyg
  1574. /*-----------------------------------------------------------------------------------*/
  1575. var handleWysiwyg = function () {
  1576. /* Init Bootstrap WYSIWYG */
  1577. function initToolbarBootstrapBindings() {
  1578. var fonts = ['Serif', 'Sans', 'Arial', 'Arial Black', 'Courier',
  1579. 'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande', 'Lucida Sans', 'Tahoma', 'Times',
  1580. 'Times New Roman', 'Verdana'],
  1581. fontTarget = $('[title=Font]').siblings('.dropdown-menu');
  1582. $.each(fonts, function (idx, fontName) {
  1583. fontTarget.append($('<li><a data-edit="fontName ' + fontName +'" style="font-family:\''+ fontName +'\'">'+fontName + '</a></li>'));
  1584. });
  1585. $('a[title]').tooltip({container:'body'});
  1586. $('.dropdown-menu input').click(function() {return false;})
  1587. .change(function () {$(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');})
  1588. .keydown('esc', function () {this.value='';$(this).change();});
  1589. $('[data-role=magic-overlay]').each(function () {
  1590. var overlay = $(this), target = $(overlay.data('target'));
  1591. overlay.css('opacity', 0).css('position', 'absolute').offset(target.offset()).width(target.outerWidth()).height(target.outerHeight());
  1592. });
  1593. if ("onwebkitspeechchange" in document.createElement("input")) {
  1594. var editorOffset = $('#editor').offset();
  1595. $('#voiceBtn').css('position','absolute').offset({top: editorOffset.top, left: editorOffset.left+$('#editor').innerWidth()-35});
  1596. } else {
  1597. $('#voiceBtn').hide();
  1598. }
  1599. };
  1600. function showErrorAlert (reason, detail) {
  1601. var msg='';
  1602. if (reason==='unsupported-file-type') { msg = "Unsupported format " +detail; }
  1603. else {
  1604. console.log("error uploading file", reason, detail);
  1605. }
  1606. $('<div class="alert"> <button type="button" class="close" data-dismiss="alert">&times;</button>'+
  1607. '<strong>File upload error</strong> '+msg+' </div>').prependTo('#alerts');
  1608. };
  1609. initToolbarBootstrapBindings();
  1610. $('#editor').wysiwyg({ fileUploadError: showErrorAlert} );
  1611. /* Disable auto-inline */
  1612. CKEDITOR.disableAutoInline = true;
  1613. }
  1614. /*-----------------------------------------------------------------------------------*/
  1615. /* Dropzone
  1616. /*-----------------------------------------------------------------------------------*/
  1617. var handleDropzone = function () {
  1618. try {
  1619. $(".dropzone").dropzone({
  1620. paramName: "file", // The name that will be used to transfer the file
  1621. maxFilesize: 0.5, // MB
  1622. addRemoveLinks : true,
  1623. dictResponseError: 'Error while uploading file!',
  1624. //change the previewTemplate to use Bootstrap progress bars
  1625. 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>"
  1626. });
  1627. } catch(e) {
  1628. alert('Dropzone.js does not support older browsers!');
  1629. }
  1630. }
  1631. /*-----------------------------------------------------------------------------------*/
  1632. /* Justgage
  1633. /*-----------------------------------------------------------------------------------*/
  1634. var handleGage = function () {
  1635. var g1, g2, g3, g4, g5, g6;
  1636. window.onload = function(){
  1637. var g1 = new JustGage({
  1638. id: "g1",
  1639. value: getRandomInt(0, 100),
  1640. min: 0,
  1641. max: 100,
  1642. title: "Custom Width",
  1643. label: "",
  1644. gaugeWidthScale: 0.2
  1645. });
  1646. var g2 = new JustGage({
  1647. id: "g2",
  1648. value: getRandomInt(0, 100),
  1649. min: 0,
  1650. max: 100,
  1651. title: "Custom Shadow",
  1652. label: "",
  1653. shadowOpacity: 1,
  1654. shadowSize: 0,
  1655. shadowVerticalOffset: 4
  1656. });
  1657. var g3 = new JustGage({
  1658. id: "g3",
  1659. value: getRandomInt(0, 100),
  1660. min: 0,
  1661. max: 100,
  1662. title: "Custom Colors",
  1663. label: "",
  1664. levelColors: [Theme.colors.red, Theme.colors.yellow, Theme.colors.green]
  1665. });
  1666. var g4 = new JustGage({
  1667. id: "g4",
  1668. value: getRandomInt(0, 100),
  1669. min: 0,
  1670. max: 100,
  1671. title: "Hide Labels",
  1672. showMinMax: false
  1673. });
  1674. var g5 = new JustGage({
  1675. id: "g5",
  1676. value: getRandomInt(0, 100),
  1677. min: 0,
  1678. max: 100,
  1679. title: "Animation Type",
  1680. label: "",
  1681. startAnimationTime: 2000,
  1682. startAnimationType: ">",
  1683. refreshAnimationTime: 1000,
  1684. refreshAnimationType: "bounce"
  1685. });
  1686. var g6 = new JustGage({
  1687. id: "g6",
  1688. value: getRandomInt(0, 100),
  1689. min: 0,
  1690. max: 100,
  1691. title: "Minimal",
  1692. label: "",
  1693. showMinMax: false,
  1694. gaugeColor: "#E6E6E6",
  1695. levelColors: ["#555555"],
  1696. showInnerShadow: false,
  1697. startAnimationTime: 1,
  1698. startAnimationType: "linear",
  1699. refreshAnimationTime: 1,
  1700. refreshAnimationType: "linear"
  1701. });
  1702. setInterval(function() {
  1703. g1.refresh(getRandomInt(0, 100));
  1704. g2.refresh(getRandomInt(0, 100));
  1705. g3.refresh(getRandomInt(0, 100));
  1706. g4.refresh(getRandomInt(0, 100));
  1707. g5.refresh(getRandomInt(0, 100));
  1708. g6.refresh(getRandomInt(0, 100));
  1709. }, 2500);
  1710. };
  1711. }
  1712. /*-----------------------------------------------------------------------------------*/
  1713. /* Sparklines
  1714. /*-----------------------------------------------------------------------------------*/
  1715. var handleSparkline = function () {
  1716. //Sparkline bar
  1717. $(".sparkline").each(function() {
  1718. var barSpacing, barWidth, color, height;
  1719. color = $(this).attr("data-color") || "red";
  1720. height = "18px";
  1721. if ($(this).hasClass("big")) {
  1722. barWidth = "5px";
  1723. barSpacing = "2px";
  1724. height = "40px";
  1725. }
  1726. return $(this).sparkline("html", {
  1727. type: "bar",
  1728. barColor: Theme.colors[color],
  1729. height: height,
  1730. barWidth: barWidth,
  1731. barSpacing: barSpacing,
  1732. zeroAxis: false
  1733. });
  1734. });
  1735. //Sparkline Pie
  1736. $(".sparklinepie").each(function() {
  1737. var height;
  1738. height = "50px";
  1739. if ($(this).hasClass("big")) {
  1740. height = "70px";
  1741. }
  1742. return $(this).sparkline("html", {
  1743. type: "pie",
  1744. height: height,
  1745. sliceColors: [Theme.colors.blue, Theme.colors.red, Theme.colors.green, Theme.colors.orange]
  1746. });
  1747. });
  1748. //Sparkline Line
  1749. $(".linechart").each(function() {
  1750. var height;
  1751. height = "18px";
  1752. if ($(this).hasClass("linechart-lg")) {
  1753. height = "30px";
  1754. }
  1755. return $(this).sparkline("html", {
  1756. type: "line",
  1757. height: height,
  1758. width: "150px",
  1759. minSpotColor: Theme.colors.red,
  1760. maxSpotColor: Theme.colors.green,
  1761. spotRadius: 3,
  1762. lineColor: Theme.colors.primary,
  1763. fillColor: "rgba(94,135,176,0.1)",
  1764. lineWidth: 1.2,
  1765. highlightLineColor: Theme.colors.red,
  1766. highlightSpotColor: Theme.colors.yellow
  1767. });
  1768. });
  1769. }
  1770. /*-----------------------------------------------------------------------------------*/
  1771. /* Handle hover in gallery
  1772. /*-----------------------------------------------------------------------------------*/
  1773. var handleHover = function () {
  1774. $('.filter-content').hover(function() {
  1775. var hoverContent = $(this).children('.hover-content');
  1776. hoverContent.removeClass('fadeOut').addClass('animated fadeIn').show();
  1777. }, function() {
  1778. var hoverContent = $(this).children('.hover-content');
  1779. hoverContent.removeClass('fadeIn').addClass('fadeOut');
  1780. });
  1781. }
  1782. /*-----------------------------------------------------------------------------------*/
  1783. /* Handle Colorbox
  1784. /*-----------------------------------------------------------------------------------*/
  1785. var handleColorbox = function () {
  1786. $('.colorbox-button').colorbox({rel:'colorbox-button',maxWidth:'95%', maxHeight:'95%'});
  1787. /* Colorbox resize function */
  1788. var resizeTimer;
  1789. function resizeColorBox()
  1790. {
  1791. if (resizeTimer) clearTimeout(resizeTimer);
  1792. resizeTimer = setTimeout(function() {
  1793. var myWidth = 442, percentageWidth = .95;
  1794. if (jQuery('#cboxOverlay').is(':visible')) {
  1795. $.colorbox.resize({ width: ( $(window).width() > ( myWidth+20) )? myWidth : Math.round( $(window).width()*percentageWidth ) });
  1796. $('.cboxPhoto').css( {
  1797. width: $('#cboxLoadedContent').innerWidth(),
  1798. height: 'auto'
  1799. });
  1800. $('#cboxLoadedContent').height( $('.cboxPhoto').height() );
  1801. $.colorbox.resize();
  1802. }
  1803. }, 300)
  1804. }
  1805. // Resize Colorbox when resizing window or changing mobile device orientation
  1806. jQuery(window).resize(resizeColorBox);
  1807. window.addEventListener("orientationchange", resizeColorBox, false);
  1808. }
  1809. /*-----------------------------------------------------------------------------------*/
  1810. /* Handle Backstretch
  1811. /*-----------------------------------------------------------------------------------*/
  1812. var handleBackstretch = function () {
  1813. // $.backstretch([
  1814. // "/usky/assets/admin/img/login/1.jpg"
  1815. // , "/usky/assets/admin/img/login/2.jpg"
  1816. // , "/usky/assets/admin/img/login/3.jpg"
  1817. // , "/usky/assets/admin/img/login/4.jpg"
  1818. // ], {duration: 3000, fade: 750});
  1819. $.backstretch([
  1820. "/assets/admin/img/login/1.jpg"
  1821. , "/assets/admin/img/login/2.jpg"
  1822. , "/assets/admin/img/login/3.jpg"
  1823. , "/assets/admin/img/login/4.jpg"
  1824. ], {duration: 3000, fade: 750});
  1825. }
  1826. /*-----------------------------------------------------------------------------------*/
  1827. /* Handle Chat
  1828. /*-----------------------------------------------------------------------------------*/
  1829. var handleChat = function (elem) {
  1830. var append = function() {
  1831. //Check if chat is empty
  1832. var input = $('.'+elem+' .chat-form input');
  1833. var text = input.val();
  1834. if (text.length == 0) {
  1835. return;
  1836. }
  1837. //Get time
  1838. var curr_time = moment().format('YYYY-MM-DD HH:mm:ss');
  1839. var msg = '';
  1840. msg +='<li class="animated fadeInLeft media">';
  1841. msg += '<a class="pull-right" href="#">';
  1842. msg += '<img class="media-object" alt="Generic placeholder image" src="img/chat/headshot2.jpg">';
  1843. msg += '</a>';
  1844. msg += '<div class="pull-right media-body chat-pop mod">';
  1845. 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>';
  1846. msg += text;
  1847. msg += '</div>';
  1848. msg +='</li>';
  1849. var list = $('.'+elem+' .chat-list');
  1850. list.append(msg);
  1851. jQuery("abbr.timeago").timeago();
  1852. input.val("");
  1853. $('.'+elem+' .scroller').slimScroll({
  1854. scrollTo: list.height()
  1855. });
  1856. }
  1857. //If button is pressed
  1858. $('.'+elem+' .chat-form .btn').click(function(e){
  1859. e.preventDefault();
  1860. append();
  1861. });
  1862. var input = $('.'+elem+' .chat-form input');
  1863. //If Enter is pressed
  1864. input.keypress(function (e) {
  1865. if (e.which == 13) {
  1866. append();
  1867. return false;
  1868. }
  1869. });
  1870. }
  1871. /*-----------------------------------------------------------------------------------*/
  1872. /* Handle Timeline
  1873. /*-----------------------------------------------------------------------------------*/
  1874. var handleTimeline = function () {
  1875. createStoryJS({
  1876. type: 'timeline',
  1877. width: '100%',
  1878. height: '600',
  1879. source: 'js/timelinejs/example_json.json',
  1880. embed_id: 'my-timeline',
  1881. debug: true,
  1882. css: 'js/timelinejs/css/timeline.css',
  1883. js: 'js/timelinejs/js/timeline-min.js'
  1884. });
  1885. }
  1886. /*-----------------------------------------------------------------------------------*/
  1887. /* Handle Slidernav
  1888. /*-----------------------------------------------------------------------------------*/
  1889. var handleSliderNav = function () {
  1890. $('#address-book').sliderNav();
  1891. $('#address-book .slider-content ul li ul li a').click(function(e){
  1892. e.preventDefault();
  1893. var contact_card = $('#contact-card');
  1894. //Get the name clicked on
  1895. var name = $(this).text();
  1896. //Set the name
  1897. $('#contact-card .panel-title').html(name);
  1898. $('#contact-card #card-name').html(name);
  1899. //Randomize the image
  1900. var img_id = Math.floor(Math.random() * (5 - 1 + 1)) + 1;
  1901. //Set the image
  1902. $('#contact-card .headshot img').attr('src', 'img/addressbook/'+img_id+'.jpg');
  1903. contact_card.removeClass('animated fadeInUp').addClass('animated fadeInUp');
  1904. var wait = window.setTimeout( function(){
  1905. contact_card.removeClass('animated fadeInUp')},
  1906. 1300
  1907. );
  1908. });
  1909. }
  1910. /*-----------------------------------------------------------------------------------*/
  1911. /* Handle Active Toggle
  1912. /*-----------------------------------------------------------------------------------*/
  1913. var handleActiveToggle = function () {
  1914. $('#list-toggle .list-group a').click(function(){
  1915. $('#list-toggle .list-group > a.active').removeClass('active');
  1916. $(this).addClass('active');
  1917. })
  1918. }
  1919. /*-----------------------------------------------------------------------------------*/
  1920. /* Handle Box Sortable
  1921. /*-----------------------------------------------------------------------------------*/
  1922. var handleBoxSortable = function () {
  1923. $('.box-container').sortable({
  1924. connectWith: '.box-container',
  1925. items:'> .box',
  1926. opacity:0.8,
  1927. revert:true,
  1928. forceHelperSize:true,
  1929. placeholder: 'box-placeholder',
  1930. forcePlaceholderSize:true,
  1931. tolerance:'pointer'
  1932. });
  1933. }
  1934. /*-----------------------------------------------------------------------------------*/
  1935. /* Handles the go to top button at the footer
  1936. /*-----------------------------------------------------------------------------------*/
  1937. var handleGoToTop = function () {
  1938. $('.footer-tools').on('click', '.go-top', function (e) {
  1939. App.scrollTo();
  1940. e.preventDefault();
  1941. });
  1942. }
  1943. /*-----------------------------------------------------------------------------------*/
  1944. /* Handles navbar fixed top
  1945. /*-----------------------------------------------------------------------------------*/
  1946. var handleNavbarFixedTop = function () {
  1947. if(is_mobile && is_fixed_header) {
  1948. //Manage margin top
  1949. $('#main-content').addClass('margin-top-100');
  1950. }
  1951. if(!(is_mobile) && is_fixed_header){
  1952. //Manage margin top
  1953. $('#main-content').removeClass('margin-top-100').addClass('margin-top-50');
  1954. }
  1955. }
  1956. /*-----------------------------------------------------------------------------------*/
  1957. /* Handles flot charts in dashboard
  1958. /*-----------------------------------------------------------------------------------*/
  1959. var handleDashFlotCharts = function () {
  1960. function chartMonth() {
  1961. var data1 = [[0, 1.5],[1, 2], [2, 1], [3, 1.5], [4, 2.5],[5, 2], [6, 2], [7, 0.5], [8, 1], [9, 1.5], [10, 2],[11, 2.5], [12, 2], [13, 1.5], [14, 2.8], [15, 2],[16, 3], [17, 2], [18, 2.5], [19, 3],[20, 2.5], [21, 2], [22, 1.5], [23, 2.5], [24, 2], [25, 1.5],[26, 1], [27, 0.5], [28, 1], [29, 1],[30, 1.5], [31, 1]];
  1962. var data2 = [[0, 2.5],[1, 3.5], [2, 2], [3, 3], [4, 4],[5, 3.5], [6, 3.5], [7, 1], [8, 2], [9, 3], [10, 4],[11, 5], [12, 4], [13, 3], [14, 5], [15, 3.5],[16, 5], [17, 4], [18, 5], [19, 6],[20, 5], [21, 4], [22, 3], [23, 5], [24, 4], [25, 3],[26, 2], [27, 1], [28, 2], [29, 2],[30, 3], [31, 2]];
  1963. var plot = $.plot($("#chart-dash"), [{
  1964. data: data2,
  1965. label: "Pageviews",
  1966. bars: {
  1967. show: true,
  1968. fill: true,
  1969. barWidth: 0.4,
  1970. align: "center",
  1971. lineWidth: 13
  1972. }
  1973. }, {
  1974. data: data1,
  1975. label: "Visits",
  1976. lines: {
  1977. show: true,
  1978. lineWidth: 2
  1979. },
  1980. points: {
  1981. show: true,
  1982. lineWidth: 2,
  1983. fill: true
  1984. },
  1985. shadowSize: 0
  1986. }, {
  1987. data: data1,
  1988. label: "Visits",
  1989. lines: {
  1990. show: true,
  1991. lineWidth: 1,
  1992. fill: true,
  1993. fillColor: {
  1994. colors: [{
  1995. opacity: 0.05
  1996. }, {
  1997. opacity: 0.01
  1998. }
  1999. ]
  2000. }
  2001. },
  2002. points: {
  2003. show: true,
  2004. lineWidth: 0.5,
  2005. fill: true
  2006. },
  2007. shadowSize: 0
  2008. }], {
  2009. grid: {
  2010. hoverable: true,
  2011. clickable: true,
  2012. tickColor: "#f7f7f7",
  2013. borderWidth: 0,
  2014. labelMargin: 10,
  2015. margin: {
  2016. top: 0,
  2017. left: 5,
  2018. bottom: 0,
  2019. right: 0
  2020. }
  2021. },
  2022. legend: {
  2023. show: false
  2024. },
  2025. colors: ["rgba(109,173,189,0.5)", "#70AFC4", "#DB5E8C"],
  2026. xaxis: {
  2027. ticks: 5,
  2028. tickDecimals: 0,
  2029. tickColor: "#fff"
  2030. },
  2031. yaxis: {
  2032. ticks: 3,
  2033. tickDecimals: 0
  2034. },
  2035. });
  2036. function showTooltip(x, y, contents) {
  2037. $('<div id="tooltip">' + contents + '</div>').css({
  2038. position: 'absolute',
  2039. display: 'none',
  2040. top: y + 5,
  2041. left: x + 15,
  2042. border: '1px solid #333',
  2043. padding: '4px',
  2044. color: '#fff',
  2045. 'border-radius': '3px',
  2046. 'background-color': '#333',
  2047. opacity: 0.80
  2048. }).appendTo("body").fadeIn(200);
  2049. }
  2050. var previousPoint = null;
  2051. $("#chart-dash").bind("plothover", function (event, pos, item) {
  2052. $("#x").text(pos.x.toFixed(2));
  2053. $("#y").text(pos.y.toFixed(2));
  2054. if (item) {
  2055. if (previousPoint != item.dataIndex) {
  2056. previousPoint = item.dataIndex;
  2057. $("#tooltip").remove();
  2058. var x = item.datapoint[0].toFixed(2),
  2059. y = item.datapoint[1].toFixed(2);
  2060. showTooltip(item.pageX, item.pageY,
  2061. item.series.label + " of " + x + " = " + y);
  2062. }
  2063. } else {
  2064. $("#tooltip").remove();
  2065. previousPoint = null;
  2066. }
  2067. });
  2068. }
  2069. //Select chart
  2070. function chart_select() {
  2071. // setup plot
  2072. function getData(x1, x2) {
  2073. var d = [];
  2074. for (var i = 0; i <= 100; ++i) {
  2075. var x = x1 + i * (x2 - x1) / 100;
  2076. d.push([x, Math.cos(x * Math.sin(x))]);
  2077. }
  2078. return [
  2079. { label: "cos(x sin(x))", data: d }
  2080. ];
  2081. }
  2082. var options = {
  2083. grid: {
  2084. hoverable: true,
  2085. clickable: true,
  2086. tickColor: "#f7f7f7",
  2087. borderWidth: 0,
  2088. labelMargin: 10,
  2089. margin: {
  2090. top: 0,
  2091. left: 5,
  2092. bottom: 0,
  2093. right: 0
  2094. }
  2095. },
  2096. legend: {
  2097. show: false
  2098. },
  2099. series: {
  2100. lines: {
  2101. show: true
  2102. },
  2103. shadowSize: 0,
  2104. points: {
  2105. show: true
  2106. }
  2107. },
  2108. colors: ["#D9534F"],
  2109. yaxis: {
  2110. ticks: 10
  2111. },
  2112. selection: {
  2113. mode: "xy",
  2114. color: "#F1ADAC"
  2115. }
  2116. };
  2117. var startData = getData(0, 3 * Math.PI);
  2118. var plot = $.plot("#placeholder", startData, options);
  2119. // Create the overview plot
  2120. var overview = $.plot($("#overview"), startData, {
  2121. legend: {
  2122. show: false
  2123. },
  2124. series: {
  2125. lines: {
  2126. show: true,
  2127. lineWidth: 1
  2128. },
  2129. shadowSize: 0
  2130. },
  2131. xaxis: {
  2132. ticks: 4
  2133. },
  2134. yaxis: {
  2135. ticks: 3,
  2136. min: -2,
  2137. max: 2
  2138. },
  2139. colors: ["#D9534F"],
  2140. grid: {
  2141. color: "#999",
  2142. borderWidth: 0,
  2143. },
  2144. selection: {
  2145. mode: "xy",
  2146. color: "#F1ADAC"
  2147. }
  2148. });
  2149. // now connect the two
  2150. $("#placeholder").bind("plotselected", function (event, ranges) {
  2151. // clamp the zooming to prevent eternal zoom
  2152. if (ranges.xaxis.to - ranges.xaxis.from < 0.00001) {
  2153. ranges.xaxis.to = ranges.xaxis.from + 0.00001;
  2154. }
  2155. if (ranges.yaxis.to - ranges.yaxis.from < 0.00001) {
  2156. ranges.yaxis.to = ranges.yaxis.from + 0.00001;
  2157. }
  2158. // do the zooming
  2159. plot = $.plot("#placeholder", getData(ranges.xaxis.from, ranges.xaxis.to),
  2160. $.extend(true, {}, options, {
  2161. xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to },
  2162. yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
  2163. })
  2164. );
  2165. // don't fire event on the overview to prevent eternal loop
  2166. overview.setSelection(ranges, true);
  2167. });
  2168. $("#overview").bind("plotselected", function (event, ranges) {
  2169. plot.setSelection(ranges);
  2170. });
  2171. // Add the Flot version string to the footer
  2172. $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
  2173. }
  2174. //Revenue chart
  2175. function chart_revenue() {
  2176. var likes = [[1, Math.random()*100], [2, Math.random()*100], [3, Math.random()*100], [4, Math.random()*100],[5,Math.random()*100],[6, Math.random()*100],[7, Math.random()*100],[8, Math.random()*100],[9, Math.random()*100],[10, Math.random()*100],[11, Math.random()*100],[12, Math.random()*100]];
  2177. var chartColor = $(this).parent().parent().css("color");
  2178. var plot = $.plot($("#chart-revenue"),
  2179. [ { data: likes} ], {
  2180. series: {
  2181. label: "Revenue",
  2182. lines: {
  2183. show: true,
  2184. lineWidth: 3,
  2185. fill: false
  2186. },
  2187. points: {
  2188. show: true,
  2189. lineWidth: 3,
  2190. fill: true,
  2191. fillColor: chartColor
  2192. },
  2193. shadowSize: 0
  2194. },
  2195. grid: { hoverable: true,
  2196. clickable: true,
  2197. tickColor: "rgba(255,255,255,.15)",
  2198. borderColor: "rgba(255,255,255,0)"
  2199. },
  2200. colors: ["#fff"],
  2201. xaxis: {
  2202. font: {
  2203. color: "#fff"
  2204. },
  2205. ticks:6,
  2206. tickDecimals: 0,
  2207. tickColor: chartColor,
  2208. },
  2209. yaxis: {
  2210. font: {
  2211. color: "#fff"
  2212. },
  2213. ticks:4,
  2214. tickDecimals: 0,
  2215. autoscaleMargin: 0.000001
  2216. },
  2217. legend: {
  2218. show: false
  2219. }
  2220. });
  2221. function showTooltip(x, y, contents) {
  2222. $('<div id="tooltip">' + contents + '</div>').css( {
  2223. position: 'absolute',
  2224. display: 'none',
  2225. top: y + 5,
  2226. left: x + 5,
  2227. border: '1px solid #fdd',
  2228. padding: '2px',
  2229. 'background-color': '#dfeffc',
  2230. opacity: 0.80
  2231. }).appendTo("body").fadeIn(200);
  2232. }
  2233. var previousPoint = null;
  2234. $("#chart-revenue").bind("plothover", function (event, pos, item) {
  2235. $("#x").text(pos.x.toFixed(2));
  2236. $("#y").text(pos.y.toFixed(2));
  2237. if (item) {
  2238. if (previousPoint != item.dataIndex) {
  2239. previousPoint = item.dataIndex;
  2240. $("#tooltip").remove();
  2241. var x = item.datapoint[0].toFixed(2),
  2242. y = item.datapoint[1].toFixed(2);
  2243. showTooltip(item.pageX, item.pageY,
  2244. item.series.label + " on " + x + " = " + y);
  2245. }
  2246. }
  2247. else {
  2248. $("#tooltip").remove();
  2249. previousPoint = null;
  2250. }
  2251. });
  2252. }
  2253. //Run the charts
  2254. chartMonth();
  2255. chart_select();
  2256. chart_revenue();
  2257. //Pie 1
  2258. $('#dash_pie_1').easyPieChart({
  2259. easing: 'easeOutBounce',
  2260. onStep: function(from, to, percent) {
  2261. $(this.el).find('.percent').text(Math.round(percent)+"%");
  2262. },
  2263. lineWidth: 6,
  2264. barColor: Theme.colors.purple
  2265. });
  2266. var chart1 = window.chart = $('#dash_pie_1').data('easyPieChart');
  2267. //Pie 2
  2268. $('#dash_pie_2').easyPieChart({
  2269. easing: 'easeOutBounce',
  2270. onStep: function(from, to, percent) {
  2271. $(this.el).find('.percent').text(Math.round(percent)+"%");
  2272. },
  2273. lineWidth: 6,
  2274. barColor: Theme.colors.yellow
  2275. });
  2276. var chart2 = window.chart = $('#dash_pie_2').data('easyPieChart');
  2277. //Pie 3
  2278. $('#dash_pie_3').easyPieChart({
  2279. easing: 'easeOutBounce',
  2280. onStep: function(from, to, percent) {
  2281. $(this.el).find('.percent').text(Math.round(percent)+"%");
  2282. },
  2283. lineWidth: 6,
  2284. barColor: Theme.colors.pink
  2285. });
  2286. var chart3 = window.chart = $('#dash_pie_3').data('easyPieChart');
  2287. //Update the charts
  2288. $('.js_update').on('click', function() {
  2289. chart1.update(Math.random()*100);
  2290. chart2.update(Math.random()*100);
  2291. chart3.update(Math.random()*100);
  2292. chart_revenue();
  2293. });
  2294. }
  2295. /*-----------------------------------------------------------------------------------*/
  2296. /* Handles vertically growing bars
  2297. /*-----------------------------------------------------------------------------------*/
  2298. var handleVerticalChart = function () {
  2299. if($('.verticalChart')) {
  2300. $('.singleBar').each(function(){
  2301. var percent = $(this).find('.value span').html();
  2302. $(this).find('.value').animate({height:percent}, 2000, function() {
  2303. $(this).find('span').fadeIn();
  2304. });
  2305. });
  2306. }
  2307. }
  2308. /*-----------------------------------------------------------------------------------*/
  2309. /* Handles theme skin switches
  2310. /*-----------------------------------------------------------------------------------*/
  2311. // var handleThemeSkins = function () {
  2312. // // Handle theme colors
  2313. // var setSkin = function (color) {
  2314. // $('#skin-switcher').attr("href", "css/themes/" + color + ".css");
  2315. // $.cookie('skin_color', color);
  2316. // }
  2317. // $('ul.skins > li a').click(function () {
  2318. // var color = $(this).data("skin");
  2319. // setSkin(color);
  2320. // });
  2321. // //Check which theme skin is set
  2322. // if ($.cookie('skin_color')) {
  2323. // setSkin($.cookie('skin_color'));
  2324. // }
  2325. // }
  2326. /*-----------------------------------------------------------------------------------*/
  2327. /* Handles Gritter on Load
  2328. /*-----------------------------------------------------------------------------------*/
  2329. var handleGritter = function () {
  2330. if ($.cookie('gritter_show')) {
  2331. return;
  2332. }
  2333. $.cookie('gritter_show', 1);
  2334. setTimeout(function () {
  2335. var unique_id = $.gritter.add({
  2336. // (string | mandatory) the heading of the notification
  2337. title: 'Welcome to usky Admin!',
  2338. // (string | mandatory) the text inside the notification
  2339. text: 'Cloud is a feature-rich Responsive Admin Dashboard Template with a wide array of plugins!',
  2340. // (string | optional) the image to display on the left
  2341. image: 'img/gritter/cloud.png',
  2342. // (bool | optional) if you want it to fade out on its own or just sit there
  2343. sticky: true,
  2344. // (int | optional) the time you want it to be alive for before fading out
  2345. time: '',
  2346. // (string | optional) the class name you want to apply to that specific message
  2347. class_name: 'my-sticky-class'
  2348. });
  2349. // You can have it return a unique id, this can be used to manually remove it later using
  2350. setTimeout(function () {
  2351. $.gritter.remove(unique_id, {
  2352. fade: true,
  2353. speed: 'slow'
  2354. });
  2355. }, 12000);
  2356. }, 2000);
  2357. setTimeout(function () {
  2358. var unique_id = $.gritter.add({
  2359. // (string | mandatory) the heading of the notification
  2360. title: 'Customize usky Admin!',
  2361. // (string | mandatory) the text inside the notification
  2362. text: 'usky Admin is easily customizable, lightweight and has a great User Experience.',
  2363. // (string | optional) the image to display on the left
  2364. image: 'img/gritter/settings.png',
  2365. // (bool | optional) if you want it to fade out on its own or just sit there
  2366. sticky: true,
  2367. // (int | optional) the time you want it to be alive for before fading out
  2368. time: '',
  2369. // (string | optional) the class name you want to apply to that specific message
  2370. class_name: 'my-sticky-class'
  2371. });
  2372. // You can have it return a unique id, this can be used to manually remove it later using
  2373. setTimeout(function () {
  2374. $.gritter.remove(unique_id, {
  2375. fade: true,
  2376. speed: 'slow'
  2377. });
  2378. }, 13000);
  2379. }, 8000);
  2380. setTimeout(function () {
  2381. $.extend($.gritter.options, {
  2382. position: 'top-left'
  2383. });
  2384. var unique_id = $.gritter.add({
  2385. position: 'top-left',
  2386. // (string | mandatory) the heading of the notification
  2387. title: 'Buy usky Admin!',
  2388. // (string | mandatory) the text inside the notification
  2389. text: 'Purchase usky Admin theme and get access to future updates at no extra cost. Buy now!',
  2390. // (string | optional) the image to display on the left
  2391. image: 'img/gritter/buy.png',
  2392. // (bool | optional) if you want it to fade out on its own or just sit there
  2393. sticky: true,
  2394. // (int | optional) the time you want it to be alive for before fading out
  2395. time: '',
  2396. // (string | optional) the class name you want to apply to that specific message
  2397. class_name: 'my-sticky-class'
  2398. });
  2399. $.extend($.gritter.options, {
  2400. position: 'top-right'
  2401. });
  2402. // You can have it return a unique id, this can be used to manually remove it later using
  2403. setTimeout(function () {
  2404. $.gritter.remove(unique_id, {
  2405. fade: true,
  2406. speed: 'slow'
  2407. });
  2408. }, 15000);
  2409. }, 15000);
  2410. setTimeout(function () {
  2411. $.extend($.gritter.options, {
  2412. position: 'top-left'
  2413. });
  2414. var unique_id = $.gritter.add({
  2415. // (string | mandatory) the heading of the notification
  2416. title: 'Notification',
  2417. // (string | mandatory) the text inside the notification
  2418. text: 'You have 6 new notifications.',
  2419. // (bool | optional) if you want it to fade out on its own or just sit there
  2420. sticky: true,
  2421. // (int | optional) the time you want it to be alive for before fading out
  2422. time: '',
  2423. // (string | optional) the class name you want to apply to that specific message
  2424. class_name: 'my-sticky-class'
  2425. });
  2426. setTimeout(function () {
  2427. $.gritter.remove(unique_id, {
  2428. fade: true,
  2429. speed: 'slow'
  2430. });
  2431. }, 4000);
  2432. $.extend($.gritter.options, {
  2433. position: 'top-right'
  2434. });
  2435. }, 20000);
  2436. setTimeout(function () {
  2437. $.extend($.gritter.options, {
  2438. position: 'top-left'
  2439. });
  2440. var unique_id = $.gritter.add({
  2441. // (string | mandatory) the heading of the notification
  2442. title: 'Inbox',
  2443. // (string | mandatory) the text inside the notification
  2444. text: 'You have 5 new messages in your inbox.',
  2445. // (bool | optional) if you want it to fade out on its own or just sit there
  2446. sticky: true,
  2447. // (int | optional) the time you want it to be alive for before fading out
  2448. time: '',
  2449. // (string | optional) the class name you want to apply to that specific message
  2450. class_name: 'my-sticky-class'
  2451. });
  2452. $.extend($.gritter.options, {
  2453. position: 'top-right'
  2454. });
  2455. setTimeout(function () {
  2456. $.gritter.remove(unique_id, {
  2457. fade: true,
  2458. speed: 'slow'
  2459. });
  2460. }, 4000);
  2461. }, 25000);
  2462. }
  2463. /*-----------------------------------------------------------------------------------*/
  2464. /* Handles Profile Edit
  2465. /*-----------------------------------------------------------------------------------*/
  2466. var handleProfileEdit = function () {
  2467. $(".datepicker").datepicker();
  2468. }
  2469. return {
  2470. //Initialise theme pages
  2471. init: function () {
  2472. if (App.isPage("index")) {
  2473. handleDataTables();
  2474. }
  2475. if (App.isPage("slider")) {
  2476. handleUploadSlider();
  2477. }
  2478. if (App.isPage("pdf")) {
  2479. handleUploadPdf();
  2480. }
  2481. if (App.isPage("indexAdd")) {
  2482. handleUploadLogo();
  2483. }
  2484. if (App.isPage("example")) {
  2485. handleExampleTables();
  2486. }
  2487. if (App.isPage("news")) {
  2488. handleNewsTables();
  2489. }
  2490. if(App.isPage('adminUserEdit')){
  2491. handleUploadAvatar();
  2492. }
  2493. if(App.isPage('adminUserModifyPassView')){
  2494. handleUserModifyPass();
  2495. }
  2496. if(App.isPage('cunstomListView')){
  2497. handleDataTables();
  2498. }
  2499. if(App.isPage('orderListView')){
  2500. handleOrderTables();
  2501. }
  2502. if(App.isPage('productionAdd')){
  2503. handleUploadAvatar();
  2504. }
  2505. //leefouce
  2506. if (App.isPage("login_bg")) {
  2507. handleUniform(); //Function to handle uniform inputs
  2508. handleBackstretch(); //Function to handle background images
  2509. handleBootbox();//Function to Bootbox
  2510. handleLogin();// Function to login
  2511. }
  2512. checkLayout(); //Function to check if mini menu/fixed header is activated
  2513. handleSidebar(); //Function to display the sidebar
  2514. handleSidebarCollapse(); //Function to hide or show sidebar
  2515. handleSidebarAndContentHeight(); //Function to hide sidebar and main content height
  2516. responsiveSidebar(); //Function to handle sidebar responsively
  2517. },
  2518. //Set page
  2519. setPage: function (name) {
  2520. currentPage = name;
  2521. },
  2522. isPage: function (name) {
  2523. return currentPage == name ? true : false;
  2524. },
  2525. //public function to add callback a function which will be called on window resize
  2526. addResponsiveFunction: function (func) {
  2527. responsiveFunctions.push(func);
  2528. },
  2529. // wrapper function to scroll(focus) to an element
  2530. scrollTo: function (el, offeset) {
  2531. pos = (el && el.size() > 0) ? el.offset().top : 0;
  2532. jQuery('html,body').animate({
  2533. scrollTop: pos + (offeset ? offeset : 0)
  2534. }, 'slow');
  2535. },
  2536. // function to scroll to the top
  2537. scrollTop: function () {
  2538. App.scrollTo();
  2539. },
  2540. // initializes uniform elements
  2541. initUniform: function (els) {
  2542. if (els) {
  2543. jQuery(els).each(function () {
  2544. if ($(this).parents(".checker").size() == 0) {
  2545. $(this).show();
  2546. $(this).uniform();
  2547. }
  2548. });
  2549. } else {
  2550. handleAllUniform();
  2551. }
  2552. },
  2553. // wrapper function to block element(indicate loading)
  2554. blockUI: function (el, loaderOnTop) {
  2555. lastBlockedUI = el;
  2556. jQuery(el).block({
  2557. message: '<img src="./img/loaders/12.gif" align="absmiddle">',
  2558. css: {
  2559. border: 'none',
  2560. padding: '2px',
  2561. backgroundColor: 'none'
  2562. },
  2563. overlayCSS: {
  2564. backgroundColor: '#000',
  2565. opacity: 0.05,
  2566. cursor: 'wait'
  2567. }
  2568. });
  2569. },
  2570. // wrapper function to un-block element(finish loading)
  2571. unblockUI: function (el) {
  2572. jQuery(el).unblock({
  2573. onUnblock: function () {
  2574. jQuery(el).removeAttr("style");
  2575. }
  2576. });
  2577. },
  2578. };
  2579. }();
  2580. (function (a, b) {
  2581. a.fn.admin_tree = function (d) {
  2582. var c = {
  2583. "open-icon": "fa fa-folder-open",
  2584. "close-icon": "fa fa-folder",
  2585. selectable: true,
  2586. "selected-icon": "fa fa-check",
  2587. "unselected-icon": "tree-dot"
  2588. };
  2589. c = a.extend({}, c, d);
  2590. this.each(function () {
  2591. var e = a(this);
  2592. 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>');
  2593. e.addClass(c.selectable == true ? "tree-selectable" : "tree-unselectable");
  2594. e.tree(c)
  2595. });
  2596. return this
  2597. }
  2598. })(window.jQuery);
  2599. (function () {
  2600. this.Theme = (function () {
  2601. function Theme() {}
  2602. Theme.colors = {
  2603. white: "#FFFFFF",
  2604. primary: "#5E87B0",
  2605. red: "#D9534F",
  2606. green: "#A8BC7B",
  2607. blue: "#70AFC4",
  2608. orange: "#F0AD4E",
  2609. yellow: "#FCD76A",
  2610. gray: "#6B787F",
  2611. lightBlue: "#D4E5DE",
  2612. purple: "#A696CE",
  2613. pink: "#DB5E8C",
  2614. dark_orange: "#F38630"
  2615. };
  2616. return Theme;
  2617. })();
  2618. })(window.jQuery);